MCPcopy Index your code
hub / github.com/python/cpython / parse_endtag

Method parse_endtag

Lib/html/parser.py:486–513  ·  view source on GitHub ↗
(self, i)

Source from the content-addressed store, hash-verified

484
485 # Internal -- parse endtag, return end or -1 if incomplete
486 def parse_endtag(self, i):
487 # See the HTML5 specs section "13.2.5.7 End tag open state"
488 # https://html.spec.whatwg.org/multipage/parsing.html#end-tag-open-state
489 rawdata = self.rawdata
490 assert rawdata[i:i+2] == "</", "unexpected call to parse_endtag"
491 if rawdata.find('>', i+2) < 0: # fast check
492 return -1
493 if not endtagopen.match(rawdata, i): # </ + letter
494 if rawdata[i+2:i+3] == '>': # </> is ignored
495 # "missing-end-tag-name" parser error
496 return i+3
497 else:
498 return self.parse_bogus_comment(i)
499
500 match = locatetagend.match(rawdata, i+2)
501 assert match
502 j = match.end()
503 if rawdata[j-1] != ">":
504 return -1
505
506 # find the name: "13.2.5.8 Tag name state"
507 # https://html.spec.whatwg.org/multipage/parsing.html#tag-name-state
508 match = tagfind_tolerant.match(rawdata, i+2)
509 assert match
510 tag = match.group(1).lower()
511 self.handle_endtag(tag)
512 self.clear_cdata_mode()
513 return j
514
515 # Overridable -- finish processing of start+end tag: <tag.../>
516 def handle_startendtag(self, tag, attrs):

Callers 1

goaheadMethod · 0.95

Calls 8

parse_bogus_commentMethod · 0.95
handle_endtagMethod · 0.95
clear_cdata_modeMethod · 0.95
findMethod · 0.45
matchMethod · 0.45
endMethod · 0.45
lowerMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected