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

Class ImageInlineProcessor

markdown/inlinepatterns.py:1203–1224  ·  view source on GitHub ↗

Return a `img` element from the given match.

Source from the content-addressed store, hash-verified

1201
1202
1203class ImageInlineProcessor(LinkInlineProcessor):
1204 """ Return a `img` element from the given match. """
1205
1206 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]:
1207 """ Return an `img` [`Element`][xml.etree.ElementTree.Element] or `(None, None, None)`. """
1208 text, index, handled = self.getText(data, m.end(0))
1209 if not handled:
1210 return None, None, None
1211
1212 src, title, index, handled = self.getLink(data, index)
1213 if not handled:
1214 return None, None, None
1215
1216 el = etree.Element("img")
1217
1218 el.set("src", src)
1219
1220 if title is not None:
1221 el.set("title", title)
1222
1223 el.set('alt', self.unescape(text))
1224 return el, m.start(0), index
1225
1226
1227class ReferenceInlineProcessor(LinkInlineProcessor):

Callers 1

build_inlinepatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected