feat(export/md): remove trilium language tag for code blocks

This commit is contained in:
Elian Doran 2024-12-17 23:40:39 +02:00
parent eee21f3741
commit 2fbdec4448
No known key found for this signature in database
2 changed files with 21 additions and 0 deletions

View File

@ -21,4 +21,21 @@ describe("Markdown export", () => {
expect(markdownExportService.toMarkdown(html)).toBe(expected);
});
it("removes auto tag for code blocks", () => {
const html = trimIndentation`\
<pre><code class="language-text-x-trilium-auto">Hello
-world
+worldy
</code></pre>`;
const expected = trimIndentation`\
\`\`\`
Hello
-world
+worldy
\`\`\``;
expect(markdownExportService.toMarkdown(html)).toBe(expected);
})
});

View File

@ -41,6 +41,10 @@ function toMarkdown(content: string) {
}
function rewriteLanguageTag(source: string) {
if (source === "text-x-trilium-auto") {
return "";
}
return source
.split("-")
.at(-1);