({
html,
markdown,
}: RichContentPlainTextOptions)
| 127 | * so link labels are preserved without leaking markdown syntax or raw URLs. |
| 128 | */ |
| 129 | export const getPlainTextFromRichContent = ({ |
| 130 | html, |
| 131 | markdown, |
| 132 | }: RichContentPlainTextOptions): string => { |
| 133 | const htmlText = stripHtmlTags(html ?? ''); |
| 134 | if (htmlText) { |
| 135 | return htmlText; |
| 136 | } |
| 137 | |
| 138 | if (!markdown) { |
| 139 | return ''; |
| 140 | } |
| 141 | |
| 142 | return stripHtmlTags(markdownToHtmlBasic(markdown)); |
| 143 | }; |
| 144 | |
| 145 | /** |
| 146 | * Escapes special markdown characters in user-generated content |
no test coverage detected