fix: mermaid
occasionally fails to initialize (#536)
This commit is contained in:
parent
6774e0e1fb
commit
48f14e39ac
1 changed files with 12 additions and 10 deletions
|
@ -5,7 +5,8 @@
|
||||||
<script src="{{ site.data.assets[origin].mermaid.js | relative_url }}"></script>
|
<script src="{{ site.data.assets[origin].mermaid.js | relative_url }}"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
(function () {
|
||||||
|
|
||||||
function updateMermaid(event) {
|
function updateMermaid(event) {
|
||||||
if (event.source === window && event.data &&
|
if (event.source === window && event.data &&
|
||||||
event.data.direction === ModeToggle.ID) {
|
event.data.direction === ModeToggle.ID) {
|
||||||
|
@ -43,15 +44,16 @@
|
||||||
theme: initTheme /* <default|dark|forest|neutral> */
|
theme: initTheme /* <default|dark|forest|neutral> */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Markdown converts to HTML */
|
/* Create mermaid tag */
|
||||||
$("pre").has("code.language-mermaid").each(function () {
|
$("pre").has("code.language-mermaid").each(function () {
|
||||||
let svgCode = $(this).children().html();
|
let svgCode = $(this).children().html();
|
||||||
$(this).addClass("unloaded");
|
$(this).addClass("unloaded");
|
||||||
$(this).after(`<div class=\"mermaid\">${svgCode}</div>`);
|
$(this).after(`<pre class=\"mermaid\">${svgCode}</pre>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
mermaid.initialize(mermaidConf);
|
mermaid.initialize(mermaidConf);
|
||||||
|
|
||||||
window.addEventListener("message", updateMermaid);
|
window.addEventListener("message", updateMermaid);
|
||||||
});
|
})();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue