* Strip markdown image badges from text. * Each pass removes image atoms, empty link wrappers, and reference defs. * Re-run to a fixed point so nested shapes like `[![…][ref]][ref]` collapse * without per-shape rules.
(text: string)
| 31 | * without per-shape rules. |
| 32 | */ |
| 33 | function stripMarkdownImages(text: string): string { |
| 34 | let previous: string |
| 35 | do { |
| 36 | previous = text |
| 37 | for (const pattern of STRIPPABLE_MARKDOWN) { |
| 38 | text = text.replace(pattern, '') |
| 39 | } |
| 40 | } while (text !== previous) |
| 41 | return text.trim() |
| 42 | } |
| 43 | |
| 44 | // Strip HTML tags and escape remaining HTML to prevent XSS |
| 45 | function stripAndEscapeHtml(text: string): string { |
no outgoing calls
no test coverage detected