From 17c6eb16809255e877f0179cae814f9e78458d3c Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 22 Jul 2025 09:09:50 +0300 Subject: [PATCH] fix(export/markdown): simple tables rendered as HTML (closes #6366) --- .../src/services/export/markdown.spec.ts | 38 ++++++++++++++++++- apps/server/src/services/export/markdown.ts | 1 + 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/apps/server/src/services/export/markdown.spec.ts b/apps/server/src/services/export/markdown.spec.ts index 6e5eb2735..ac9d2aa04 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} - >
12
34
+ > | | | + > | --- | --- | + > | 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*/`\ +
+ + + + + + + + + + + +
+ Hi + + there +
+ Hi + + there +
+
+ `; + 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.ts index f68a8d87e..6bbaf386d 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;