From 418ffb83c3e321885b7ebf1e3f342934344ffdcc Mon Sep 17 00:00:00 2001 From: Mikhail Bratchikov Date: Thu, 6 Jun 2024 16:12:11 +0300 Subject: [PATCH] Add mermaid diagrams rendering --- static/js/markdown_client.js | 7 +++++++ templates/markdown_view.html | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/static/js/markdown_client.js b/static/js/markdown_client.js index ff600e4..5d622d2 100644 --- a/static/js/markdown_client.js +++ b/static/js/markdown_client.js @@ -32,9 +32,15 @@ document.addEventListener('DOMContentLoaded', function() { } } + const renderMermaid = async () => { + await window.mermaid.run({ + querySelector: '.language-mermaid', + }); + }; syntaxHighlight(); renderMath(); + renderMermaid(); var previewWindow = document.getElementById('markdown-preview'); var webSocketUrl = 'ws://' + window.location.host; @@ -45,6 +51,7 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('markdown-preview').innerHTML = event.data; syntaxHighlight(); renderMath(); + renderMermaid(); } socket.onclose = function(event) { diff --git a/templates/markdown_view.html b/templates/markdown_view.html index 54ade4b..56d85bf 100644 --- a/templates/markdown_view.html +++ b/templates/markdown_view.html @@ -30,6 +30,11 @@ +