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): title extraction not working due to h1 conversion
Elian Doran6056b55bde3b
diff --git a/src/services/import/single.ts b/src/services/import/single.tsindex 18b22329f4..4f50a686d1 100644--- a/src/services/import/single.ts+++ b/src/services/import/single.ts@@ -150,15 +150,16 @@ function importMarkdown(taskContext: TaskContext, file: File, parentNote: BNote)function importHtml(taskContext: TaskContext, file: File, parentNote: BNote) {let content = file.buffer.toString("utf-8");-- if (taskContext?.data?.safeImport) {- content = htmlSanitizer.sanitize(content);- }-+// Try to get title from HTML first, fall back to filename+ // We do this before sanitization since that turns all <h1>s into <h2>const htmlTitle = importUtils.extractHtmlTitle(content);const title = htmlTitle || utils.getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces);-++ if (taskContext?.data?.safeImport) {+ content = htmlSanitizer.sanitize(content);+ }+content = importUtils.handleH1(content, title);const {note} = noteService.createNewNote({