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

Class EscapeInlineProcessor

markdown/inlinepatterns.py:316–332  ·  view source on GitHub ↗

Return an escaped character.

Source from the content-addressed store, hash-verified

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

Callers 1

build_inlinepatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected