Convert HTML entity patterns, see https://spec.commonmark.org/0.30/#entity-references
(match: str, name: str)
| 96 | |
| 97 | |
| 98 | def 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 | |
| 117 | def unescapeAll(string: str) -> str: |
no test coverage detected
searching dependent graphs…