Merge pull request #2070 from ZhenShuo2021/fix/mermaid

🐛 fix: Preserve Mermaid indentation disrupted by Hugo minify (#2069)
This commit is contained in:
Nuno Coração
2025-05-01 16:36:03 +01:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@@ -2,6 +2,17 @@ function css(name) {
return "rgb(" + getComputedStyle(document.documentElement).getPropertyValue(name) + ")";
}
document.addEventListener("DOMContentLoaded", () => {
const mermaidDivs = document.querySelectorAll("div.mermaid");
for (const div of mermaidDivs) {
const preElement = div.querySelector("pre");
if (preElement) {
div.textContent = preElement.textContent;
}
}
});
mermaid.initialize({
theme: "base",
themeVariables: {
@@ -17,4 +28,4 @@ mermaid.initialize({
"ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,segoe ui,Roboto,helvetica neue,Arial,noto sans,sans-serif",
fontSize: "16px",
},
});
});

View File

@@ -1,3 +1,3 @@
<div class="mermaid" align="center">
{{ .Inner }}
<pre>{{ .Inner | safeHTML }}</pre>
</div>