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

Method handleMatch

markdown/inlinepatterns.py:882–902  ·  view source on GitHub ↗

Return [`Element`][xml.etree.ElementTree.Element] returned by `makeTag` method or `(None, None, None)`.

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

Source from the content-addressed store, hash-verified

880 RE_LINK = re.compile(r'\s?\[([^\]]*)\]', re.DOTALL | re.UNICODE)
881
882 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]:
883 """
884 Return [`Element`][xml.etree.ElementTree.Element] returned by `makeTag` method or `(None, None, None)`.
885
886 """
887 text, index, handled = self.getText(data, m.end(0))
888 if not handled:
889 return None, None, None
890
891 id, end, handled = self.evalId(data, index, text)
892 if not handled:
893 return None, None, None
894
895 # Clean up line breaks in id
896 id = self.NEWLINE_CLEANUP_RE.sub(' ', id)
897 if id not in self.md.references: # ignore undefined refs
898 return None, m.start(0), end
899
900 href, title = self.md.references[id]
901
902 return self.makeTag(href, title, text), m.start(0), end
903
904 def evalId(self, data: str, index: int, text: str) -> tuple[str | None, int, bool]:
905 """

Callers

nothing calls this directly

Calls 3

evalIdMethod · 0.95
makeTagMethod · 0.95
getTextMethod · 0.80

Tested by

no test coverage detected