Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(import/single): h1 not being removed due to downgrade to h2
Elian Dorancef464f88b73
diff --git a/src/services/import/single.ts b/src/services/import/single.tsindex 4f50a686d1..c20fec3b0a 100644--- a/src/services/import/single.ts+++ b/src/services/import/single.ts@@ -156,11 +156,12 @@ function importHtml(taskContext: TaskContext, file: File, parentNote: BNote) {const htmlTitle = importUtils.extractHtmlTitle(content);const title = htmlTitle || utils.getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces);+ content = importUtils.handleH1(content, title);+if (taskContext?.data?.safeImport) {content = htmlSanitizer.sanitize(content);- }+ }- content = importUtils.handleH1(content, title);const {note} = noteService.createNewNote({parentNoteId: parentNote.noteId,diff --git a/src/services/import/utils.ts b/src/services/import/utils.tsindex ea3cb075e4..ec4bbf35a6 100644--- a/src/services/import/utils.ts+++ b/src/services/import/utils.ts@@ -1,7 +1,7 @@"use strict";function handleH1(content: string, title: string) {- content = content.replace(/<h1>([^<]*)<\/h1>/gi, (match, text) => {+ content = content.replace(/<h1[^>]*>([^<]*)<\/h1>/gi, (match, text) => {if (title.trim() === text.trim()) {return ""; // remove whole H1 tag} else {