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

Class ImageInlineProcessor

markdown/inlinepatterns.py:1315–1336  ·  view source on GitHub ↗

Return a `img` element from the given match.

Source from the content-addressed store, hash-verified

1313
1314
1315class ImageInlineProcessor(LinkInlineProcessor):
1316 """ Return a `img` element from the given match. """
1317
1318 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]:
1319 """ Return an `img` [`Element`][xml.etree.ElementTree.Element] or `(None, None, None)`. """
1320 text, index, handled = self.getText(data, m.end(0))
1321 if not handled:
1322 return None, None, None
1323
1324 src, title, index, handled = self.getLink(data, index)
1325 if not handled:
1326 return None, None, None
1327
1328 el = etree.Element("img")
1329
1330 el.set("src", src)
1331
1332 if title is not None:
1333 el.set("title", title)
1334
1335 el.set('alt', self.unescape(text))
1336 return el, m.start(0), index
1337
1338
1339class ReferenceInlineProcessor(LinkInlineProcessor):

Callers 1

build_inlinepatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected