MCPcopy Index your code
hub / github.com/Python-Markdown/markdown / unescape

Method unescape

markdown/inlinepatterns.py:511–528  ·  view source on GitHub ↗

Return unescaped text given text with an inline placeholder.

(self, text: str)

Source from the content-addressed store, hash-verified

509 return place_holder, m.start(0), m.end(0)
510
511 def unescape(self, text: str) -> str:
512 """ Return unescaped text given text with an inline placeholder. """
513 try:
514 stash = self.md.treeprocessors['inline'].stashed_nodes
515 except KeyError: # pragma: no cover
516 return text
517
518 def get_stash(m: re.Match[str]) -> str:
519 id = m.group(1)
520 value = stash.get(id)
521 if value is not None:
522 try:
523 # Ensure we don't have a placeholder inside a placeholder
524 return self.unescape(self.md.serializer(value))
525 except Exception:
526 return r'\%s' % value
527
528 return util.INLINE_PLACEHOLDER_RE.sub(get_stash, text)
529
530 def backslash_unescape(self, text: str) -> str:
531 """ Return text with backslash escapes undone (backslashes are restored). """

Callers 2

handleMatchMethod · 0.95
get_stashMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected