fix: decode other entity text as well

pull/341/head
Daniel Roe 2022-12-05 00:30:20 +00:00
rodzic 4146915a33
commit 09290b112e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 22D5008E4F5D9B55
1 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -43,6 +43,12 @@ function handleNode(el: Node) {
return handleCodeBlock(el) || handleMention(el) || el
}
const decoder = document.createElement('textarea')
function decode(text: string) {
decoder.innerHTML = text
return decoder.value
}
/**
* Parse raw HTML form Mastodon server to AST,
* with interop of custom emojis and inline Markdown syntax
@ -72,7 +78,7 @@ export function parseMastodonHTML(html: string, customEmojis: Record<string, Emo
[/\*(.*?)\*/g, '<em>$1</em>'],
[/~~(.*?)~~/g, '<del>$1</del>'],
[/`([^`]+?)`/g, '<code>$1</code>'],
[/&#(\d+);/g, (_: string, dec: string) => String.fromCharCode(Number(dec))],
[/&[^;]+;/g, (val: string) => decode(val)],
] as any
for (const [re, replacement] of replacements) {