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

Method substitute_match

markdown/postprocessors.py:75–86  ·  view source on GitHub ↗
(m: re.Match[str])

Source from the content-addressed store, hash-verified

73 def run(self, text: str) -> str:
74 """ Iterate over html stash and restore html. """
75 def substitute_match(m: re.Match[str]) -> str:
76 if key := m.group(1):
77 wrapped = True
78 else:
79 key = m.group(2)
80 wrapped = False
81 if (key := int(key)) >= self.md.htmlStash.html_counter:
82 return m.group(0)
83 html = self.stash_to_string(self.md.htmlStash.rawHtmlBlocks[key])
84 if not wrapped or self.isblocklevel(html):
85 return pattern.sub(substitute_match, html)
86 return pattern.sub(substitute_match, f"<p>{html}</p>")
87
88 if self.md.htmlStash.html_counter:
89 base_placeholder = util.HTML_PLACEHOLDER % r'([0-9]+)'

Callers

nothing calls this directly

Calls 2

stash_to_stringMethod · 0.95
isblocklevelMethod · 0.95

Tested by

no test coverage detected