From 20bcd84d7eb1daa47f72eefd593e44cf7a63bbcb Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 23 Mar 2025 14:25:15 +0100 Subject: [PATCH] Render line breaks in change lot HTML representation --- .../website/[websiteId]/logs/+page.svelte | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte b/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte index db8cf9c..4176c81 100644 --- a/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte +++ b/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte @@ -141,9 +141,13 @@ {#if form?.logId === id && form?.currentDiff} -
{@html DOMPurify.sanitize(form.currentDiff, {
- ALLOWED_TAGS: ["ins", "del"]
- })}
+ {@html DOMPurify.sanitize(
+ // .replace takes escaped text representations of line breaks and converts them to real line breaks that render correctly in HTML
+ form.currentDiff.replace(/\\r\\n|\\n|\\r/g, "\n"),
+ {
+ ALLOWED_TAGS: ["ins", "del"]
+ }
+ )}
{/if}
{/if}