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

Method handleMatch

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

1231 RE_LINK = re.compile(r'\s?\[([^\]]*)\]', re.DOTALL | re.UNICODE)
1232
1233 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]:
1234 """
1235 Return [`Element`][xml.etree.ElementTree.Element] returned by `makeTag` method or `(None, None, None)`.
1236
1237 """
1238 text, index, handled = self.getText(data, m.end(0))
1239 if not handled:
1240 return None, None, None
1241
1242 id, end, handled = self.evalId(data, index, text)
1243 if not handled:
1244 return None, None, None
1245
1246 # Clean up line breaks in id
1247 id = self.NEWLINE_CLEANUP_RE.sub(' ', id)
1248 if id not in self.md.references: # ignore undefined refs
1249 return None, m.start(0), end
1250
1251 href, title = self.md.references[id]
1252
1253 return self.makeTag(href, title, text), m.start(0), end
1254
1255 def evalId(self, data: str, index: int, text: str) -> tuple[str | None, int, bool]:
1256 """

Callers

nothing calls this directly

Calls 3

evalIdMethod · 0.95
makeTagMethod · 0.95
getTextMethod · 0.80

Tested by

no test coverage detected