MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / replaceEntityPattern

Function replaceEntityPattern

markdown_it/common/utils.py:98–114  ·  view source on GitHub ↗

Convert HTML entity patterns, see https://spec.commonmark.org/0.30/#entity-references

(match: str, name: str)

Source from the content-addressed store, hash-verified

96
97
98def replaceEntityPattern(match: str, name: str) -> str:
99 """Convert HTML entity patterns,
100 see https://spec.commonmark.org/0.30/#entity-references
101 """
102 if name in entities:
103 return entities[name]
104
105 code: None | int = None
106 if pat := DIGITAL_ENTITY_BASE10_RE.fullmatch(name):
107 code = int(pat.group(1), 10)
108 elif pat := DIGITAL_ENTITY_BASE16_RE.fullmatch(name):
109 code = int(pat.group(1), 16)
110
111 if code is not None and isValidEntityCode(code):
112 return fromCodePoint(code)
113
114 return match
115
116
117def unescapeAll(string: str) -> str:

Callers 1

replacer_funcFunction · 0.85

Calls 2

isValidEntityCodeFunction · 0.85
fromCodePointFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…