diff --git a/src/services/import/utils.ts b/src/services/import/utils.ts
index 2f4227f0a..41c42ae22 100644
--- a/src/services/import/utils.ts
+++ b/src/services/import/utils.ts
@@ -3,16 +3,17 @@
function handleH1(content: string, title: string) {
let isFirstH1Handled = false;
- content = content.replace(/
]*>([^<]*)<\/h1>/gi, (match, text) => {
- if (title.trim() === text.trim() && !isFirstH1Handled) {
+ return content.replace(/]*>([^<]*)<\/h1>/gi, (match, text) => {
+ const convertedContent = `${text}
`;
+
+ // strip away very first found h1 tag, if it matches the title
+ if (!isFirstH1Handled) {
isFirstH1Handled = true;
- return ""; // remove whole H1 tag
- } else {
- isFirstH1Handled = true;
- return `${text}
`;
+ return title.trim() === text.trim() ? "" : convertedContent;
}
+
+ return convertedContent;
});
- return content;
}
function extractHtmlTitle(content: string): string | null {