Created
September 19, 2022 16:32
-
-
Save sajith-rahim/5ab4c6f02fc41159eb2390a8346a7bc6 to your computer and use it in GitHub Desktop.
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
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script> | |
<script> | |
mermaid.initialize({startOnLoad:true}); | |
</script> | |
<style> | |
.mermaid { /* add custom styling */ } | |
</style> | |
<!--This will render scripts when the document loads once. | |
If you dynamically change the document in JavaScript that affects the Mermaid code (like page navigation in SPA apps), you might need to update and re-render the diagrams. The code below is from Markdown Monster which uses an event to trigger a re-render when the Previewer content is refreshed (without a full page reload): | |
--> | |
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script> | |
<script> | |
mermaid.initialize({startOnLoad:false}); | |
</script> | |
<script> | |
function renderMermaid(){ | |
mermaid.init(undefined,document.querySelectorAll(".mermaid")); | |
} | |
$(function() { | |
$(document).on('previewUpdated', function() { | |
renderMermaid(); | |
}); | |
renderMermaid(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment