mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
feat(import/single): support UTF-16 LE with BOM for markdown notes
This commit is contained in:
parent
77ee7f96c1
commit
c925ae5f15
BIN
src/services/import/samples/UTF-16LE Text Note.md
Normal file
BIN
src/services/import/samples/UTF-16LE Text Note.md
Normal file
Binary file not shown.
@ -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");
|
||||
});
|
||||
})
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user