MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / parse_comment

Method parse_comment

markdown/htmlparser.py:361–378  ·  view source on GitHub ↗
(self, i, report=True)

Source from the content-addressed store, hash-verified

359 # Internal -- parse comment, return length or -1 if not terminated
360 # see https://html.spec.whatwg.org/multipage/parsing.html#comment-start-state
361 def parse_comment(self, i, report=True):
362 rawdata = self.rawdata
363 assert rawdata.startswith('<!--', i), 'unexpected call to parse_comment()'
364 # If no close was found after an earlier position in the same `rawdata`, there
365 # is none after this one either. Don't rescan the rest of the document again.
366 searched, pos = self._no_commentclose
367 if searched is rawdata and i + 4 >= pos:
368 match = None
369 else:
370 match = commentclose.search(rawdata, i+4)
371 if not match:
372 self._no_commentclose = (rawdata, i + 4)
373 self.handle_data('<')
374 return i + 1
375 if report:
376 j = match.start()
377 self.handle_comment(rawdata[i+4: j])
378 return match.end()
379
380 def parse_html_declaration(self, i: int) -> int:
381 if self.at_line_start() or self.intail:

Callers

nothing calls this directly

Calls 3

handle_dataMethod · 0.95
handle_commentMethod · 0.95
searchMethod · 0.80

Tested by

no test coverage detected