MCPcopy
hub / github.com/Python-Markdown/markdown / EscapeInlineProcessor

Class EscapeInlineProcessor

markdown/inlinepatterns.py:345–361  ·  view source on GitHub ↗

Return an escaped character.

Source from the content-addressed store, hash-verified

343
344
345class EscapeInlineProcessor(InlineProcessor):
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 1

build_inlinepatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…