* Decodes known HTML entities in a single pass to avoid double-unescaping. * A two-step decode (e.g. `&` -> `&` then `<` -> `<`) would turn * `&lt;` into `<`, which is incorrect.
(text: string)
| 130 | * `&lt;` into `<`, which is incorrect. |
| 131 | */ |
| 132 | function decodeHtmlEntities(text: string): string { |
| 133 | return text.replace(/&(?:nbsp|amp|lt|gt|quot|#39);/g, (match) => HTML_ENTITY_MAP[match] ?? match) |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Basic HTML to text extraction. |
no test coverage detected