Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mermaid support, rendering in sandbox iframe #245

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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