From 6d81dc97ea712af13491d26c451eab5d7d744b4a Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Tue, 17 Sep 2024 19:23:47 -0400 Subject: [PATCH] Don't escape code in multiline blocks --- src/pages/_utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/_utils.ts b/src/pages/_utils.ts index b5660cbd5b..2ae7261c70 100644 --- a/src/pages/_utils.ts +++ b/src/pages/_utils.ts @@ -233,6 +233,10 @@ export const escapeCodeTagsContent = (htmlString: string): string => { const $ = load(htmlString); // Loop through all tags $("code").each(function () { + // Don't escape code in multiline blocks, as these will already + // be escaped + if ($(this).parent().prop('tagName') === 'PRE') return; + // Get the current text and HTML inside the tag const currentHtml = $(this).html() ?? ""; // Use he to escape HTML entities