From 95a962813e64634f58df512d9eaf54f785b83d0e Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Sat, 23 Nov 2024 10:28:18 -0800 Subject: [PATCH] Revise code block render hook for Mermaid diagrams See: - https://discourse.gohugo.io/t/52506/10 - https://github.com/mermaid-js/mermaid/issues/6075 --- content/en/content-management/diagrams.md | 2 +- content/en/render-hooks/code-blocks.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/en/content-management/diagrams.md b/content/en/content-management/diagrams.md index 8851034c6c..f9f3cd30f6 100644 --- a/content/en/content-management/diagrams.md +++ b/content/en/content-management/diagrams.md @@ -52,7 +52,7 @@ Hugo does not provide a built-in template for Mermaid diagrams. Create your own {{< code file=layouts/_default/_markup/render-codeblock-mermaid.html >}}
-  {{- .Inner | safeHTML }}
+  {{- .Inner | htmlEscape | safeHTML }}
 
{{ .Page.Store.Set "hasMermaid" true }} {{< /code >}} diff --git a/content/en/render-hooks/code-blocks.md b/content/en/render-hooks/code-blocks.md index d322cb88dc..f43df06c7c 100755 --- a/content/en/render-hooks/code-blocks.md +++ b/content/en/render-hooks/code-blocks.md @@ -122,7 +122,7 @@ For example, to create a code block render hook to render [Mermaid] diagrams: {{< code file=layouts/_default/_markup/render-codeblock-mermaid.html copy=true >}}
-  {{- .Inner | safeHTML }}
+  {{- .Inner | htmlEscape | safeHTML }}
 
{{ .Page.Store.Set "hasMermaid" true }} {{< /code >}}