perf: replace unescapeHtml DOMParser with html-entities decode (#23165)
This commit is contained in:
1 parent
354a179f6d
commit
2d83d0f950
1 file changed
+3
-3
@@ -22,6 +22,7 @@ import { marked } from 'marked';
|
|||||||
import markedExtension from '$lib/utils/marked/extension';
|
import markedExtension from '$lib/utils/marked/extension';
|
||||||
import markedKatexExtension from '$lib/utils/marked/katex-extension';
|
import markedKatexExtension from '$lib/utils/marked/katex-extension';
|
||||||
import hljs from 'highlight.js';
|
import hljs from 'highlight.js';
|
||||||
|
import { decode } from 'html-entities';
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// Helper functions
|
// Helper functions
|
||||||
@@ -167,9 +168,8 @@ function processChineseDelimiters(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function unescapeHtml(html: string) {
|
export function unescapeHtml(html: string): string {
|
||||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
return decode(html);
|
||||||
return doc.documentElement.textContent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const capitalizeFirstLetter = (string) => {
|
export const capitalizeFirstLetter = (string) => {
|
||||||
|
|||||||
Reference in new issue
Block a user