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

Method handleMatch

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

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

Callers

nothing calls this directly

Calls 1

find_code_spansMethod · 0.95

Tested by

no test coverage detected