feat: removing pre and code

This commit is contained in:
Chubby Granny Chaser
2025-10-17 15:33:10 +01:00
parent 24f7ecb795
commit 393c55738c

View File

@@ -39,6 +39,12 @@ export function sanitizeHtml(html: string): string {
}
}
// Remove code and pre tags but keep their text content
for (const el of tempDiv.querySelectorAll("code, pre")) {
const textNode = document.createTextNode(el.textContent || "");
el.replaceWith(textNode);
}
for (const el of tempDiv.querySelectorAll("*")) {
for (const attr of Array.from(el.attributes)) {
const name = attr.name.toLowerCase();