(self, i)
| 360 | # See w3.org/TR/html5/tokenization.html#markup-declaration-open-state |
| 361 | # See also parse_declaration in _markupbase |
| 362 | def parse_html_declaration(self, i): |
| 363 | rawdata = self.rawdata |
| 364 | assert rawdata[i:i+2] == '<!', ('unexpected call to ' |
| 365 | 'parse_html_declaration()') |
| 366 | if rawdata[i:i+4] == '<!--': |
| 367 | # this case is actually already handled in goahead() |
| 368 | return self.parse_comment(i) |
| 369 | elif rawdata[i:i+9] == '<![CDATA[' and self._support_cdata: |
| 370 | j = rawdata.find(']]>', i+9) |
| 371 | if j < 0: |
| 372 | return -1 |
| 373 | self.unknown_decl(rawdata[i+3: j]) |
| 374 | return j + 3 |
| 375 | elif rawdata[i:i+9].lower() == '<!doctype': |
| 376 | # find the closing > |
| 377 | gtpos = rawdata.find('>', i+9) |
| 378 | if gtpos == -1: |
| 379 | return -1 |
| 380 | self.handle_decl(rawdata[i+2:gtpos]) |
| 381 | return gtpos+1 |
| 382 | else: |
| 383 | return self.parse_bogus_comment(i) |
| 384 | |
| 385 | # Internal -- parse comment, return length or -1 if not terminated |
| 386 | # see https://html.spec.whatwg.org/multipage/parsing.html#comment-start-state |
no test coverage detected