fix: decode numerically encoded html entities in text
parent
408aff20ee
commit
4146915a33
|
@ -72,7 +72,9 @@ export function parseMastodonHTML(html: string, customEmojis: Record<string, Emo
|
||||||
[/\*(.*?)\*/g, '<em>$1</em>'],
|
[/\*(.*?)\*/g, '<em>$1</em>'],
|
||||||
[/~~(.*?)~~/g, '<del>$1</del>'],
|
[/~~(.*?)~~/g, '<del>$1</del>'],
|
||||||
[/`([^`]+?)`/g, '<code>$1</code>'],
|
[/`([^`]+?)`/g, '<code>$1</code>'],
|
||||||
] as const
|
[/&#(\d+);/g, (_: string, dec: string) => String.fromCharCode(Number(dec))],
|
||||||
|
] as any
|
||||||
|
|
||||||
for (const [re, replacement] of replacements) {
|
for (const [re, replacement] of replacements) {
|
||||||
for (const match of node.value.matchAll(re)) {
|
for (const match of node.value.matchAll(re)) {
|
||||||
if (node.loc) {
|
if (node.loc) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Vitest Snapshot v1
|
// Vitest Snapshot v1
|
||||||
|
|
||||||
exports[`html-parse > code frame > html 1`] = `
|
exports[`html-parse > code frame > html 1`] = `
|
||||||
"<p>Testing code block</p><p><pre><code class=\\"language-ts\\">import { useMouse, usePreferredDark } from '@vueuse/core'
|
"<p>Testing code block</p><p><pre><code class=\\"language-ts\\">import { useMouse, usePreferredDark } from '@vueuse/core'
|
||||||
// tracks mouse position
|
// tracks mouse position
|
||||||
const { x, y } = useMouse()
|
const { x, y } = useMouse()
|
||||||
// is the user prefers dark theme
|
// is the user prefers dark theme
|
||||||
|
@ -12,7 +12,7 @@ exports[`html-parse > code frame > text 1`] = `
|
||||||
"Testing code block
|
"Testing code block
|
||||||
|
|
||||||
\`\`\`ts
|
\`\`\`ts
|
||||||
import { useMouse, usePreferredDark } from '@vueuse/core'
|
import { useMouse, usePreferredDark } from '@vueuse/core'
|
||||||
// tracks mouse position
|
// tracks mouse position
|
||||||
const { x, y } = useMouse()
|
const { x, y } = useMouse()
|
||||||
// is the user prefers dark theme
|
// is the user prefers dark theme
|
||||||
|
|
Loading…
Reference in New Issue