(html: string)
| 18 | * Strips HTML tags from content and decodes common HTML entities. |
| 19 | */ |
| 20 | export function htmlToPlainText(html: string): string { |
| 21 | let text = html.replace(/<[^>]*>/g, ' ') |
| 22 | text = text |
| 23 | .replace(/ /g, ' ') |
| 24 | .replace(/</g, '<') |
| 25 | .replace(/>/g, '>') |
| 26 | .replace(/"/g, '"') |
| 27 | .replace(/'/g, "'") |
| 28 | .replace(/&/g, '&') |
| 29 | return text.replace(/\s+/g, ' ').trim() |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Computes a SHA-256 hash of the given content string. |
no test coverage detected