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(export/markdown): simple tables rendered as HTML (closes #6366)
Elian Doran17c6eb168092
diff --git a/apps/server/src/services/export/markdown.spec.ts b/apps/server/src/services/export/markdown.spec.tsindex 6e5eb27350..ac9d2aa04e 100644--- a/apps/server/src/services/export/markdown.spec.ts+++ b/apps/server/src/services/export/markdown.spec.ts@@ -176,7 +176,10 @@ describe("Markdown export", () => {> [!IMPORTANT]> This is a very important information.>${space}- > <figure class="table"><table><tbody><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></tbody></table></figure>+ > | | |+ > | --- | --- |+ > | 1 | 2 |+ > | 3 | 4 |> [!CAUTION]> This is a caution.@@ -342,4 +345,37 @@ describe("Markdown export", () => {expect(markdownExportService.toMarkdown(html)).toBe(expected);});+ it("exports unformatted table", () => {+ const html = trimIndentation/*html*/`\+ <figure class="table">+ <table>+ <tbody>+ <tr>+ <td>+ Hi+ </td>+ <td>+ there+ </td>+ </tr>+ <tr>+ <td>+ Hi+ </td>+ <td>+ there+ </td>+ </tr>+ </tbody>+ </table>+ </figure>+ `;+ const expected = trimIndentation`\+ | | |+ | --- | --- |+ | Hi | there |+ | Hi | there |`;+ expect(markdownExportService.toMarkdown(html)).toBe(expected);+ });+});diff --git a/apps/server/src/services/export/markdown.ts b/apps/server/src/services/export/markdown.tsindex f68a8d87e1..6bbaf386d3 100644--- a/apps/server/src/services/export/markdown.ts+++ b/apps/server/src/services/export/markdown.ts@@ -209,6 +209,7 @@ function buildFigureFilter(): Rule {return {filter(node, options) {return node.nodeName === 'FIGURE'+ && node.classList.contains("image");},replacement(content, node) {return (node as HTMLElement).outerHTML;