MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / handleMatch

Method handleMatch

markdown/inlinepatterns.py:277–296  ·  view source on GitHub ↗
(self, m)

Source from the content-addressed store, hash-verified

275class ImagePattern(LinkPattern):
276 """ Return a img element from the given match. """
277 def handleMatch(self, m):
278 el = markdown.etree.Element("img")
279 src_parts = m.group(9).split()
280 if src_parts:
281 src = src_parts[0]
282 if src[0] == "<" and src[-1] == ">":
283 src = src[1:-1]
284 el.set('src', self.sanitize_url(src))
285 else:
286 el.set('src', "")
287 if len(src_parts) > 1:
288 el.set('title', dequote(" ".join(src_parts[1:])))
289
290 if markdown.ENABLE_ATTRIBUTES:
291 truealt = handleAttributes(m.group(2), el)
292 else:
293 truealt = m.group(2)
294
295 el.set('alt', truealt)
296 return el
297
298class ReferencePattern(LinkPattern):
299 """ Match to a stored reference and return link element. """

Callers

nothing calls this directly

Calls 5

setMethod · 0.95
dequoteFunction · 0.85
handleAttributesFunction · 0.85
sanitize_urlMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected