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

Method handleMatch

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

1343 RE_LINK = re.compile(r'\s?\[([^\]]*)\]', re.DOTALL | re.UNICODE)
1344
1345 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]:
1346 """
1347 Return [`Element`][xml.etree.ElementTree.Element] returned by `makeTag` method or `(None, None, None)`.
1348
1349 """
1350 text, index, handled = self.getText(data, m.end(0))
1351 if not handled:
1352 return None, None, None
1353
1354 id, end, handled = self.evalId(data, index, text)
1355 if not handled:
1356 return None, None, None
1357
1358 # Clean up line breaks in id
1359 id = self.NEWLINE_CLEANUP_RE.sub(' ', id)
1360 if id not in self.md.references: # ignore undefined refs
1361 return None, m.start(0), end
1362
1363 href, title = self.md.references[id]
1364
1365 return self.makeTag(href, title, text), m.start(0), end
1366
1367 def evalId(self, data: str, index: int, text: str) -> tuple[str | None, int, bool]:
1368 """

Callers

nothing calls this directly

Calls 3

evalIdMethod · 0.95
makeTagMethod · 0.95
getTextMethod · 0.80

Tested by

no test coverage detected