Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(markdown/import): markdown quotes not escaping
Elian Doran6a3c44f866e8
diff --git a/src/services/import/markdown.spec.ts b/src/services/import/markdown.spec.tsindex 2a7330091c..f3f9515f88 100644--- a/src/services/import/markdown.spec.ts+++ b/src/services/import/markdown.spec.ts@@ -127,4 +127,10 @@ second line 2</code></pre><ul><li>Hello</li><li>world</li></ul><ol><li>Hello</liexpect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);});+ it("does not escape unneeded characters", () => {+ const input = `It's important to note that these examples are not natively supported by Trilium out of the box; instead, they demonstrate what you can build within Trilium.`;+ const expected = `<p>It's important to note that these examples are not natively supported by Trilium out of the box; instead, they demonstrate what you can build within Trilium.</p>`;+ expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);+ });+});diff --git a/src/services/import/markdown.ts b/src/services/import/markdown.tsindex aa714d253d..95ff3b1244 100644--- a/src/services/import/markdown.ts+++ b/src/services/import/markdown.ts@@ -82,7 +82,7 @@ function renderToHtml(content: string, title: string) {// h1 handling needs to come before sanitizationhtml = importUtils.handleH1(html, title);- // html = htmlSanitizer.sanitize(html);+ html = htmlSanitizer.sanitize(html);// Remove slash for self-closing tags to match CKEditor's approach.html = html.replace(/<(\w+)([^>]*)\s+\/>/g, "<$1$2>");