Skip to content

Commit

Permalink
Merge pull request #245 from HL7/add-mermaid
Browse files Browse the repository at this point in the history
Add mermaid support, rendering in sandbox iframe
  • Loading branch information
grahamegrieve authored Jul 30, 2024
2 parents 28305b9 + 063693e commit 6b8a84c
Show file tree
Hide file tree
Showing 4 changed files with 2,044 additions and 3 deletions.
12 changes: 12 additions & 0 deletions content/assets/js/mermaid-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
document.addEventListener('DOMContentLoaded', function() {
const mermaidCodes = document.querySelectorAll('pre.language-mermaid code.language-mermaid');
Array.from(mermaidCodes).forEach(function(code) {
const pre = code.parentNode;
const content = code.textContent;
const mermaidDiv = document.createElement('div');
mermaidDiv.className = 'mermaid';
mermaidDiv.textContent = content;
pre.parentNode.replaceChild(mermaidDiv, pre);
});
mermaid.initialize({ securityLevel: 'sandbox' });
});
2,029 changes: 2,029 additions & 0 deletions content/assets/js/mermaid.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion includes/fragment-pagebegin.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<body onload="document.body.style.opacity='1'">
{% assign label = {{site.data.pages[page.path].label}} | split: '.0' %}
<script src="{{site.data.info.assets}}assets/js/prism.js"></script>

<script type="text/javascript" src="{{site.data.info.assets}}assets/js/mermaid.js"></script>
<script type="text/javascript" src="{{site.data.info.assets}}assets/js/mermaid-init.js"></script>
<style type="text/css">h2{--heading-prefix:"{{site.data.info.headingOffset}}{{label}}"}
h3,h4,h5,h6{--heading-prefix:"{{site.data.info.headingOffset}}{{site.data.pages[page.path].label}}"}</style>
<div id="segment-header" class="segment"> <!-- segment-header -->
Expand Down
3 changes: 1 addition & 2 deletions includes/fragment-pageend.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<div class="container"> <!-- container -->
</div> <!-- /container -->
</div> <!-- /segment-post-footer -->

<!-- JS and analytics only. -->
<!-- Bootstrap core JavaScript
================================================== -->
Expand All @@ -66,7 +66,6 @@
<script type="text/javascript" src="assets/js/clipboard.min.js"> </script>
<script type="text/javascript" src="assets/js/clipboard-btn.js"> </script>
<script type="text/javascript" src="{{site.data.info.assets}}assets/js/anchor-hover.js"> </script>

<!-- Analytics Below
================================================== -->
</body>
Expand Down

0 comments on commit 6b8a84c

Please sign in to comment.