From 8def1b3e59ca16fe20fbcbbd27ef4424a00b691f Mon Sep 17 00:00:00 2001 From: Ole Mussmann Date: Sat, 25 Jan 2025 21:06:35 +0100 Subject: [PATCH] fix mermaid diagram rendering closes #69 --- layouts/_default/_markup/render-codeblock-mermaid.html | 4 ++-- static/js/copy-code.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/layouts/_default/_markup/render-codeblock-mermaid.html b/layouts/_default/_markup/render-codeblock-mermaid.html index bb7bf42..dcd9c98 100644 --- a/layouts/_default/_markup/render-codeblock-mermaid.html +++ b/layouts/_default/_markup/render-codeblock-mermaid.html @@ -1,4 +1,4 @@
-  {{- .Inner | safeHTML }}
+  {{- .Inner | htmlEscape | safeHTML }}
 
-{{ .Page.Store.Set "hasMermaid" true }} \ No newline at end of file +{{ .Page.Store.Set "hasMermaid" true }} diff --git a/static/js/copy-code.js b/static/js/copy-code.js index 67fd936..2de3cda 100644 --- a/static/js/copy-code.js +++ b/static/js/copy-code.js @@ -2,6 +2,7 @@ document.addEventListener("DOMContentLoaded", function () { const codeBlocks = document.querySelectorAll("pre"); codeBlocks.forEach((codeBlock) => { + if (codeBlock.className == "mermaid") return; const copyButton = document.createElement("button"); copyButton.className = "copy-code-button"; copyButton.textContent = "copy";