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

Method handleMatch

markdown/inlinepatterns.py:1139–1158  ·  view source on GitHub ↗

Return an `a` [`Element`][xml.etree.ElementTree.Element] or `(None, None, None)`.

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

Source from the content-addressed store, hash-verified

1137 self._bracket_ends: list[int | None] = []
1138
1139 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]:
1140 """ Return an `a` [`Element`][xml.etree.ElementTree.Element] or `(None, None, None)`. """
1141 text, index, handled = self.getText(data, m.end(0))
1142
1143 if not handled:
1144 return None, None, None
1145
1146 href, title, index, handled = self.getLink(data, index)
1147 if not handled:
1148 return None, None, None
1149
1150 el = etree.Element("a")
1151 el.text = text
1152
1153 el.set("href", href)
1154
1155 if title is not None:
1156 el.set("title", title)
1157
1158 return el, m.start(0), index
1159
1160 def getLink(self, data: str, index: int) -> tuple[str, str | None, int, bool]:
1161 """Parse data between `()` of `[Text]()` allowing recursive `()`. """

Callers

nothing calls this directly

Calls 3

getTextMethod · 0.95
getLinkMethod · 0.95
setMethod · 0.80

Tested by

no test coverage detected