-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,28 +117,29 @@ defmodule Workspace.MixProject do | |
|
||
defp before_closing_body_tag(:html) do | ||
""" | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function () { | ||
mermaid.initialize({ | ||
startOnLoad: false, | ||
theme: document.body.className.includes("dark") ? "dark" : "default" | ||
}); | ||
let id = 0; | ||
for (const codeEl of document.querySelectorAll("pre code.mermaid")) { | ||
const preEl = codeEl.parentElement; | ||
const graphDefinition = codeEl.textContent; | ||
const graphEl = document.createElement("div"); | ||
const graphId = "mermaid-graph-" + id++; | ||
mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => { | ||
graphEl.innerHTML = svg; | ||
bindFunctions?.(graphEl); | ||
preEl.insertAdjacentElement("afterend", graphEl); | ||
preEl.remove(); | ||
function mermaidLoaded() { | ||
document.addEventListener("DOMContentLoaded", function () { | ||
mermaid.initialize({ | ||
startOnLoad: false, | ||
theme: document.body.className.includes("dark") ? "dark" : "default" | ||
}); | ||
} | ||
}); | ||
let id = 0; | ||
for (const codeEl of document.querySelectorAll("pre code.mermaid")) { | ||
const preEl = codeEl.parentElement; | ||
const graphDefinition = codeEl.textContent; | ||
const graphEl = document.createElement("div"); | ||
const graphId = "mermaid-graph-" + id++; | ||
mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => { | ||
graphEl.innerHTML = svg; | ||
bindFunctions?.(graphEl); | ||
preEl.insertAdjacentElement("afterend", graphEl); | ||
preEl.remove(); | ||
}); | ||
} | ||
} | ||
</script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" onload="mermaidLoaded();"></script> | ||
""" | ||
end | ||
|
||
|