fix(export/markdown): simple tables rendered as HTML (closes #6366)

This commit is contained in:
Elian Doran 2025-07-22 09:09:50 +03:00
parent 7c6af568d8
commit 17c6eb1680
No known key found for this signature in database
2 changed files with 38 additions and 1 deletions

View File

@ -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);
});
});

View File

@ -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;