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

Class SubstituteTextPattern

markdown/extensions/smarty.py:164–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162
163
164class SubstituteTextPattern(HtmlInlineProcessor):
165 def __init__(self, pattern: str, replace: Sequence[int | str | etree.Element], md: Markdown):
166 """ Replaces matches with some text. """
167 HtmlInlineProcessor.__init__(self, pattern)
168 self.replace = replace
169 self.md = md
170
171 def handleMatch(self, m: re.Match[str], data: str) -> tuple[str, int, int]:
172 result = ''
173 for part in self.replace:
174 if isinstance(part, int):
175 result += m.group(part)
176 else:
177 result += self.md.htmlStash.store(part)
178 return result, m.start(0), m.end(0)
179
180
181class SmartyExtension(Extension):

Callers 4

_addPatternsMethod · 0.85
educateDashesMethod · 0.85
educateEllipsesMethod · 0.85
educateAngledQuotesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected