feat: emoji font
This commit is contained in:
parent
30c8e82dbf
commit
d9b0e85f63
5 changed files with 35 additions and 11 deletions
|
@ -2,6 +2,8 @@ import type { Emoji } from 'masto'
|
|||
import type { Node } from 'ultrahtml'
|
||||
import { TEXT_NODE, parse, render, walkSync } from 'ultrahtml'
|
||||
|
||||
const EMOJI_REGEX = /(\p{Emoji_Presentation})/ug
|
||||
|
||||
const decoder = process.client ? document.createElement('textarea') : null as any as HTMLTextAreaElement
|
||||
export function decodeHtml(text: string) {
|
||||
decoder.innerHTML = text
|
||||
|
@ -21,6 +23,7 @@ export function parseMastodonHTML(html: string, customEmojis: Record<string, Emo
|
|||
return `<img src="${emoji.url}" alt=":${name}:" class="custom-emoji" data-emoji-id="${name}" />`
|
||||
return `:${name}:`
|
||||
})
|
||||
.replace(EMOJI_REGEX, '<em-emoji native="$1" />')
|
||||
|
||||
if (markdown) {
|
||||
// handle code blocks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue