mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 17:36:44 +02:00
fix(markdown): mermaid not rendering
This commit is contained in:
@@ -70,6 +70,11 @@ describe("renderWithSourceLines", () => {
|
||||
expect(html).toContain('<aside class="admonition note">');
|
||||
});
|
||||
|
||||
it("preserves the `mermaid` fence language so the mermaid rewrite can match it", () => {
|
||||
const html = renderWithSourceLines("```mermaid\ngraph TD;\nA-->B;\n```");
|
||||
expect(html).toContain('class="language-mermaid"');
|
||||
});
|
||||
|
||||
it("produces math-tex spans for inline math", () => {
|
||||
const html = renderWithSourceLines("Energy: $e=mc^2$.");
|
||||
expect(html).toContain('<span class="math-tex">');
|
||||
|
||||
@@ -155,7 +155,10 @@ class CustomMarkdownRenderer extends Renderer {
|
||||
|
||||
text = escapeHtml(text).replace(/"/g, '"');
|
||||
|
||||
const ckEditorLanguage = getNormalizedMimeFromMarkdownLanguage(lang);
|
||||
// `mermaid` isn't in the MIME dictionary, but CKEditor/Trilium's
|
||||
// mermaid rewrite specifically looks for `language-mermaid`, so
|
||||
// preserve the fence language verbatim instead of falling back to auto.
|
||||
const ckEditorLanguage = lang === "mermaid" ? "mermaid" : getNormalizedMimeFromMarkdownLanguage(lang);
|
||||
return `<pre><code class="language-${ckEditorLanguage}">${text}</code></pre>`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user