* Escapes HTML special characters so raw code can be safely injected via * `dangerouslySetInnerHTML` as the plaintext fallback before Prism loads (and * for unknown languages). Matches Prism's own escaping for visual parity. * * @param text - The raw code text to escape * @returns The HTML-esca
(text: string)
| 88 | * @returns The HTML-escaped text |
| 89 | */ |
| 90 | function escapeHtml(text: string): string { |
| 91 | return text |
| 92 | .replace(/&/g, '&') |
| 93 | .replace(/</g, '<') |
| 94 | .replace(/>/g, '>') |
| 95 | .replace(/"/g, '"') |
| 96 | .replace(/'/g, ''') |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Highlights a single line of code, falling back to escaped plaintext when Prism |
no test coverage detected