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

Method handleMatch

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

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

Source from the content-addressed store, hash-verified

442 """ The tag of the rendered element. """
443
444 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | str, int, int]:
445 """
446 If the match contains `group(3)` of a pattern, then return a `code`
447 [`Element`][xml.etree.ElementTree.Element] which contains HTML escaped text (with
448 [`code_escape`][markdown.util.code_escape]) as an [`AtomicString`][markdown.util.AtomicString].
449
450 If the match does not contain `group(3)` then return the text of `group(1)` backslash escaped.
451
452 """
453 if m.group(3):
454 el = etree.Element(self.tag)
455 el.text = util.AtomicString(util.code_escape(m.group(3).strip()))
456 return el, m.start(0), m.end(0)
457 else:
458 return m.group(1).replace('\\\\', self.ESCAPED_BSLASH), m.start(0), m.end(0)
459
460
461class DoubleTagPattern(SimpleTagPattern): # pragma: no cover

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected