(html: string)
| 108 | // fidelity through html-to-docx. |
| 109 | const EMPTY_BLOCK_RE = /<(h[1-6]|code|pre|div|blockquote)\b[^>]*>\s*<\/\1>/gi; |
| 110 | export const dropEmptyBlocks = (html: string): string => { |
| 111 | let prev: string; |
| 112 | let cur = html; |
| 113 | do { |
| 114 | prev = cur; |
| 115 | cur = cur.replace(EMPTY_BLOCK_RE, ''); |
| 116 | } while (cur !== prev); |
| 117 | return cur; |
| 118 | }; |
| 119 | |
| 120 | // Wrap loose text + inline content in `<p>` blocks so html-to-docx renders |
| 121 | // `<br>` as a soft line break (`<w:br/>`) instead of a paragraph break |
no outgoing calls
no test coverage detected