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

Method run

markdown/extensions/md_in_html.py:391–411  ·  view source on GitHub ↗
(self, parent: etree.Element, blocks: list[str])

Source from the content-addressed store, hash-verified

389 child.tail = util.AtomicString(child.tail)
390
391 def run(self, parent: etree.Element, blocks: list[str]) -> bool:
392 m = util.HTML_PLACEHOLDER_RE.match(blocks[0])
393 if m:
394 index = int(m.group(1))
395 element = self.parser.md.htmlStash.rawHtmlBlocks[index]
396 if isinstance(element, etree.Element):
397 # We have a matched element. Process it.
398 block = blocks.pop(0)
399 parent.append(element)
400 self.parse_element_content(element)
401 # Cleanup stash. Replace element with empty string to avoid confusing postprocessor.
402 self.parser.md.htmlStash.rawHtmlBlocks.pop(index)
403 self.parser.md.htmlStash.rawHtmlBlocks.insert(index, '')
404 content = block[m.end(0):]
405 # Ensure the rest of the content gets handled
406 if content:
407 blocks.insert(0, content)
408 # Confirm the match to the `blockparser`.
409 return True
410 # No match found.
411 return False
412
413
414class MarkdownInHTMLPostprocessor(RawHtmlPostprocessor):

Callers

nothing calls this directly

Calls 1

parse_element_contentMethod · 0.95

Tested by

no test coverage detected