Skip to content

Build your personal knowledge base with Trilium Notes

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

Elian Doran2fbdec4448a8
diff --git a/spec/services/export/md.spec.ts b/spec/services/export/md.spec.ts
index 612b43513a..980f7fa2cc 100644
--- a/spec/services/export/md.spec.ts
+++ b/spec/services/export/md.spec.ts
@@ -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);
+ })
});
\ No newline at end of file
diff --git a/src/services/export/md.ts b/src/services/export/md.ts
index 8f7213f842..4669dd68ed 100644
--- a/src/services/export/md.ts
+++ b/src/services/export/md.ts
@@ -41,6 +41,10 @@ function toMarkdown(content: string) {
}
function rewriteLanguageTag(source: string) {
+ if (source === "text-x-trilium-auto") {
+ return "";
+ }
+
return source
.split("-")
.at(-1);