feat(import/markdown): preserve language tags when possible

This commit is contained in:
Elian Doran
2025-01-11 15:21:32 +02:00
parent 0e67078256
commit 9db9d412d9
6 changed files with 271 additions and 201 deletions

View File

@@ -16,4 +16,27 @@ describe("markdown", () => {
<p>Hello, world</p>
`);
});
it("rewrites language of known language tags", () => {
const result = markdownService.renderToHtml(trimIndentation`\
\`\`\`javascript
Hi
\`\`\`
\`\`\`css
there
\`\`\`
`, "title");
expect(result).toBe(trimIndentation`\
<pre><code class="language-application-javascript-env-backend">Hi</code></pre><pre><code class="language-text-css">there</code></pre>`);
});
it("rewrites language of unknown language tags", () => {
const result = markdownService.renderToHtml(trimIndentation`\
\`\`\`unknownlanguage
Hi
\`\`\`
`, "title");
expect(result).toBe(trimIndentation`\
<pre><code class="language-text-x-trilium-auto">Hi</code></pre>`);
});
});