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

Method handleMatch

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

693 RE_TITLE_CLEAN = re.compile(r'\s')
694
695 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]:
696 """ Return an `a` [`Element`][xml.etree.ElementTree.Element] or `(None, None, None)`. """
697 text, index, handled = self.getText(data, m.end(0))
698
699 if not handled:
700 return None, None, None
701
702 href, title, index, handled = self.getLink(data, index)
703 if not handled:
704 return None, None, None
705
706 el = etree.Element("a")
707 el.text = text
708
709 el.set("href", href)
710
711 if title is not None:
712 el.set("title", title)
713
714 return el, m.start(0), index
715
716 def getLink(self, data: str, index: int) -> tuple[str, str | None, int, bool]:
717 """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