File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -13,5 +13,41 @@ canonical = System.fetch_env!("CANONICAL")
1313 logger: "https://hexdocs.pm/logger/#{ canonical } " ,
1414 mix: "https://hexdocs.pm/mix/#{ canonical } "
1515 ] ,
16- formatters: [ "html" , "epub" ]
16+ formatters: [ "html" , "epub" ] ,
17+ before_closing_body_tag: fn
18+ :html ->
19+ """
20+ <script defer src="https://cdn.jsdelivr.net/npm/mermaid@10.2.3/dist/mermaid.min.js"></script>
21+ <script>
22+ let initialized = false;
23+
24+ window.addEventListener("exdoc:loaded", () => {
25+ if (!initialized) {
26+ mermaid.initialize({
27+ startOnLoad: false,
28+ theme: document.body.className.includes("dark") ? "dark" : "default"
29+ });
30+ initialized = true;
31+ }
32+
33+ let id = 0;
34+ for (const codeEl of document.querySelectorAll("pre code.mermaid")) {
35+ const preEl = codeEl.parentElement;
36+ const graphDefinition = codeEl.textContent;
37+ const graphEl = document.createElement("div");
38+ const graphId = "mermaid-graph-" + id++;
39+ mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => {
40+ graphEl.innerHTML = svg;
41+ bindFunctions?.(graphEl);
42+ preEl.insertAdjacentElement("afterend", graphEl);
43+ preEl.remove();
44+ });
45+ }
46+ });
47+ </script>
48+ """
49+
50+ _ ->
51+ ""
52+ end
1753]
You can’t perform that action at this time.
0 commit comments