forked from alshedivat/al-folio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed mermaid support in template (alshedivat#1992)
Fix alshedivat#1609 --------- Signed-off-by: George Araujo <george.gcac@gmail.com> Co-authored-by: Maruan Al-Shedivat <maruan@genesistherapeutics.ai>
- Loading branch information
1 parent
576dd8f
commit 9ce3f06
Showing
10 changed files
with
120 additions
and
41 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
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
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% if page.mermaid and page.mermaid.enabled %} | ||
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script> | ||
{% if page.mermaid.zoomable %} | ||
<script src="https://d3js.org/d3.v7.min.js"></script> | ||
{% endif %} | ||
<script> | ||
let theme = localStorage.getItem("theme"); | ||
|
||
/* Create mermaid diagram as another node and hide the code block, appending the mermaid node after it | ||
this is done to enable retrieving the code again when changing theme between light/dark */ | ||
document.querySelectorAll('pre>code.language-mermaid').forEach((elem) => { | ||
const svgCode = elem.textContent; | ||
const backup = elem.parentElement; | ||
backup.classList.add('unloaded'); | ||
/* create mermaid node */ | ||
let mermaid = document.createElement('pre'); | ||
mermaid.classList.add('mermaid'); | ||
const text = document.createTextNode(svgCode); | ||
mermaid.appendChild(text); | ||
backup.after(mermaid); | ||
}); | ||
|
||
mermaid.initialize({ theme: theme }) | ||
|
||
/* Zoomable mermaid diagrams */ | ||
if (typeof d3 !== 'undefined') { | ||
window.addEventListener('load', function () { | ||
var svgs = d3.selectAll(".mermaid svg"); | ||
svgs.each(function () { | ||
var svg = d3.select(this); | ||
svg.html("<g>" + svg.html() + "</g>"); | ||
var inner = svg.select("g"); | ||
var zoom = d3.zoom().on("zoom", function (event) { | ||
inner.attr("transform", event.transform); | ||
}); | ||
svg.call(zoom); | ||
}); | ||
}); | ||
} | ||
</script> | ||
{% endif %} |
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
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
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
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
This file was deleted.
Oops, something went wrong.
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