| 14 | } |
| 15 | |
| 16 | export function fixHTML(html: string) { |
| 17 | // Replace any gray styles with zinc, fix placeholder images |
| 18 | // TODO: this is kinda LAME |
| 19 | let fixed = html.replaceAll('-gray-', '-zinc-') |
| 20 | // Use placehold.co for images |
| 21 | fixed = fixed.replaceAll('via.placeholder.com', 'placehold.co') |
| 22 | fixed = fixed.replaceAll('via.placeholder.co', 'placehold.co') |
| 23 | fixed = fixed.replaceAll('placehold.it', 'placehold.co') |
| 24 | // Point to our own backend for mp3's / wav files |
| 25 | fixed = fixed.replaceAll( |
| 26 | /"[^"]*\.(mp3|wav)|'[^']*\.(mp3|wav)'/g, |
| 27 | `"${document.location.origin}/openui/funky.mp3"` |
| 28 | ) |
| 29 | // Point svg's to our own backend |
| 30 | fixed = fixed.replaceAll( |
| 31 | /"[^"?]+\/([^/]+)\.svg(["?])/g, |
| 32 | `"${document.location.origin}/openui/$1.svg$2` |
| 33 | ) |
| 34 | // Remove any comments in the HTML |
| 35 | fixed = fixed.replaceAll(/<!--[\S\s]*?-->/g, '') |
| 36 | return fixed |
| 37 | } |
| 38 | |
| 39 | export function parseMarkdown( |
| 40 | markdown: string, |