From 393c55738c284d729bee2d45e8f891d1e52538d8 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Fri, 17 Oct 2025 15:33:10 +0100 Subject: [PATCH] feat: removing pre and code --- src/shared/html-sanitizer.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shared/html-sanitizer.ts b/src/shared/html-sanitizer.ts index 8f3ae932..0969564d 100644 --- a/src/shared/html-sanitizer.ts +++ b/src/shared/html-sanitizer.ts @@ -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();