(html: string)
| 1906 | } |
| 1907 | |
| 1908 | export function convertToEmoji(html: string): string { |
| 1909 | return html.replace( |
| 1910 | /(<code[\s>][\s\S]*?<\/code>|<pre[\s>][\s\S]*?<\/pre>)|(:[\w+-]+:)/gi, |
| 1911 | (match, codeBlock: string | undefined, shortcode: string | undefined) => { |
| 1912 | if (codeBlock) return codeBlock |
| 1913 | if (shortcode) { |
| 1914 | const key = shortcode.slice(1, -1) |
| 1915 | return emojis[key] ?? shortcode |
| 1916 | } |
| 1917 | return match |
| 1918 | }, |
| 1919 | ) |
| 1920 | } |
no outgoing calls
no test coverage detected