From 1de9bc7c6f955772c23f00647127bd6d1c097bbd Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 21 Jan 2025 00:04:05 +0100 Subject: [PATCH] fix(import/utils.handleH1): fix stripping of all

tags that match title now it will only strip the very first tag that if it matches the title, otherwise it gets turned into a h2 tag fixes #1016 --- src/services/import/utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/import/utils.ts b/src/services/import/utils.ts index ec4bbf35a..2f4227f0a 100644 --- a/src/services/import/utils.ts +++ b/src/services/import/utils.ts @@ -1,10 +1,14 @@ "use strict"; function handleH1(content: string, title: string) { + let isFirstH1Handled = false; + content = content.replace(/]*>([^<]*)<\/h1>/gi, (match, text) => { - if (title.trim() === text.trim()) { + if (title.trim() === text.trim() && !isFirstH1Handled) { + isFirstH1Handled = true; return ""; // remove whole H1 tag } else { + isFirstH1Handled = true; return `

${text}

`; } });