feat(import/single): support UTF-16 LE with BOM for markdown notes

This commit is contained in:
Elian Doran 2025-02-22 01:09:24 +02:00
parent 77ee7f96c1
commit c925ae5f15
No known key found for this signature in database
3 changed files with 7 additions and 1 deletions

Binary file not shown.

View File

@ -72,4 +72,10 @@ describe("processNoteContent", () => {
expect(importedNote.mime).toBe("text/html");
expect(importedNote.getContent().toString()).toBe("<p>Plain text goes here.<br></p>");
});
it("supports markdown note with UTF-16", async () => {
const { importedNote } = await testImport("UTF-16LE Text Note.md", "text/markdown");
expect(importedNote.mime).toBe("text/html");
expect(importedNote.getContent().toString()).toBe("<h2>Hello world</h2>\n<p>Plain text goes here.</p>\n");
});
})

View File

@ -127,7 +127,7 @@ function convertTextToHtml(text: string) {
function importMarkdown(taskContext: TaskContext, file: File, parentNote: BNote) {
const title = getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces);
const markdownContent = file.buffer.toString("utf-8");
const markdownContent = processStringOrBuffer(file.buffer);
let htmlContent = markdownService.renderToHtml(markdownContent, title);
if (taskContext.data?.safeImport) {