From 6056b55bde3b0f31b24daff0fb7ddebdb9f603ee Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 28 Nov 2024 19:30:47 +0200 Subject: [PATCH] fix(import/single): title extraction not working due to h1 conversion --- src/services/import/single.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/services/import/single.ts b/src/services/import/single.ts index 18b22329f..4f50a686d 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"); - + + // Try to get title from HTML first, fall back to filename + // We do this before sanitization since that turns all

s into

+ const htmlTitle = importUtils.extractHtmlTitle(content); + const title = htmlTitle || utils.getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces); + if (taskContext?.data?.safeImport) { content = htmlSanitizer.sanitize(content); } - - // Try to get title from HTML first, fall back to filename - const htmlTitle = importUtils.extractHtmlTitle(content); - const title = htmlTitle || utils.getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces); - + content = importUtils.handleH1(content, title); const {note} = noteService.createNewNote({