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

Method handleMatch

markdown/inlinepatterns.py:320–333  ·  view source on GitHub ↗

If the character matched by `group(1)` of a pattern is in [`ESCAPED_CHARS`][markdown.Markdown.ESCAPED_CHARS] then return the integer representing the character's Unicode code point (as returned by [`ord`][]) wrapped in [`util.STX`][markdown.util.STX] and [`util.ETX`][markdow

(self, m: re.Match[str], data: str)

Source from the content-addressed store, hash-verified

318 """ Return an escaped character. """
319
320 def handleMatch(self, m: re.Match[str], data: str) -> tuple[str | None, int, int]:
321 """
322 If the character matched by `group(1)` of a pattern is in [`ESCAPED_CHARS`][markdown.Markdown.ESCAPED_CHARS]
323 then return the integer representing the character's Unicode code point (as returned by [`ord`][]) wrapped
324 in [`util.STX`][markdown.util.STX] and [`util.ETX`][markdown.util.ETX].
325
326 If the matched character is not in [`ESCAPED_CHARS`][markdown.Markdown.ESCAPED_CHARS], then return `None`.
327 """
328
329 char = m.group(1)
330 if char in self.md.ESCAPED_CHARS:
331 return '{}{}{}'.format(util.STX, ord(char), util.ETX), m.start(0), m.end(0)
332 else:
333 return None, m.start(0), m.end(0)
334
335
336class SimpleTagPattern(Pattern): # pragma: no cover

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected