fix(import/single): title extraction not working due to h1 conversion

This commit is contained in:
Elian Doran 2024-11-28 19:30:47 +02:00
parent 5999dabd0b
commit 6056b55bde
No known key found for this signature in database

View File

@ -151,14 +151,15 @@ 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 <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);
}
// 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({