perf: replace parse5
with ultrahtml
(#336)
This commit is contained in:
parent
04615e443e
commit
1c0f8b0147
8 changed files with 94 additions and 143 deletions
|
@ -1,7 +1,7 @@
|
|||
import type { Emoji } from 'masto'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { format } from 'prettier'
|
||||
import { serialize } from 'parse5'
|
||||
import { render as renderTree } from 'ultrahtml'
|
||||
import { parseMastodonHTML, treeToText } from '~/composables/content'
|
||||
|
||||
describe('html-parse', () => {
|
||||
|
@ -53,9 +53,9 @@ describe('html-parse', () => {
|
|||
|
||||
async function render(input: string, emojis?: Record<string, Emoji>) {
|
||||
const tree = parseMastodonHTML(input, emojis)
|
||||
const html = serialize(tree)
|
||||
const html = await renderTree(tree)
|
||||
let formatted = ''
|
||||
const serializedText = tree.childNodes.map(n => treeToText(n)).join('').trim()
|
||||
const serializedText = tree.children.map(n => treeToText(n)).join('').trim()
|
||||
|
||||
try {
|
||||
formatted = format(html, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue