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

Method handleMatch

markdown/inlinepatterns.py:459–478  ·  view source on GitHub ↗

If the match contains `group(3)` of a pattern, then return a `code` [`Element`][xml.etree.ElementTree.Element] which contains HTML escaped text (with [`code_escape`][markdown.util.code_escape]) as an [`AtomicString`][markdown.util.AtomicString]. If the match contain

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

Source from the content-addressed store, hash-verified

457 return start + max_ticks, None
458
459 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | str | None, int | None, int | None]:
460 """
461 If the match contains `group(3)` of a pattern, then return a `code`
462 [`Element`][xml.etree.ElementTree.Element] which contains HTML escaped text (with
463 [`code_escape`][markdown.util.code_escape]) as an [`AtomicString`][markdown.util.AtomicString].
464
465 If the match contains `group(1)` then return the text of `group(1)` as backslash escaped.
466
467 """
468 if m.group(1):
469 return m.group(1).replace('\\\\', self.ESCAPED_BSLASH), m.start(0), m.end(0)
470
471 begin = m.start(0)
472 start, end = self.find_code_spans(begin, data)
473 if end is not None:
474 el = etree.Element(self.tag)
475 el.text = util.AtomicString(util.code_escape(data[start:end].strip()))
476 return el, begin, end + (start - begin)
477 # Skip over backtick group as we could find no match
478 return None, begin, start
479
480
481class DoubleTagPattern(SimpleTagPattern): # pragma: no cover

Callers

nothing calls this directly

Calls 1

find_code_spansMethod · 0.95

Tested by

no test coverage detected