mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	feat(import/single): support UTF-16 LE with BOM for markdown notes
This commit is contained in:
		
							
								
								
									
										
											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.mime).toBe("text/html"); | ||||||
|         expect(importedNote.getContent().toString()).toBe("<p>Plain text goes here.<br></p>"); |         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) { | function importMarkdown(taskContext: TaskContext, file: File, parentNote: BNote) { | ||||||
|     const title = getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces); |     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); |     let htmlContent = markdownService.renderToHtml(markdownContent, title); | ||||||
|  |  | ||||||
|     if (taskContext.data?.safeImport) { |     if (taskContext.data?.safeImport) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user