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

Method handleMatch

markdown/inlinepatterns.py:348–361  ·  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

346 """ Return an escaped character. """
347
348 def handleMatch(self, m: re.Match[str], data: str) -> tuple[str | None, int, int]:
349 """
350 If the character matched by `group(1)` of a pattern is in [`ESCAPED_CHARS`][markdown.Markdown.ESCAPED_CHARS]
351 then return the integer representing the character's Unicode code point (as returned by [`ord`][]) wrapped
352 in [`util.STX`][markdown.util.STX] and [`util.ETX`][markdown.util.ETX].
353
354 If the matched character is not in [`ESCAPED_CHARS`][markdown.Markdown.ESCAPED_CHARS], then return `None`.
355 """
356
357 char = m.group(1)
358 if char in self.md.ESCAPED_CHARS:
359 return '{}{}{}'.format(util.STX, ord(char), util.ETX), m.start(0), m.end(0)
360 else:
361 return None, m.start(0), m.end(0)
362
363
364class SimpleTagPattern(Pattern): # pragma: no cover

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected