Skip to content

Instantly share code, notes, and snippets.

@sajith-rahim
Created September 19, 2022 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sajith-rahim/5ab4c6f02fc41159eb2390a8346a7bc6 to your computer and use it in GitHub Desktop.
Save sajith-rahim/5ab4c6f02fc41159eb2390a8346a7bc6 to your computer and use it in GitHub Desktop.
<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