Skip to content

Commit 26e48f2

Browse files
committed
perf: replace unescapeHtml DOMParser with html-entities decode
1 parent e3c8e75 commit 26e48f2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/lib/utils/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { marked } from 'marked';
2222
import markedExtension from '$lib/utils/marked/extension';
2323
import markedKatexExtension from '$lib/utils/marked/katex-extension';
2424
import hljs from 'highlight.js';
25+
import { decode } from 'html-entities';
2526

2627
//////////////////////////
2728
// Helper functions
@@ -168,9 +169,8 @@ function processChineseDelimiters(
168169
});
169170
}
170171

171-
export function unescapeHtml(html: string) {
172-
const doc = new DOMParser().parseFromString(html, 'text/html');
173-
return doc.documentElement.textContent;
172+
export function unescapeHtml(html: string): string {
173+
return decode(html);
174174
}
175175

176176
export const capitalizeFirstLetter = (string) => {

0 commit comments

Comments
 (0)