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

Class EscapeInlineProcessor

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

Return an escaped character.

Source from the content-addressed store, hash-verified

315
316
317class EscapeInlineProcessor(InlineProcessor):
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 1

build_inlinepatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected