Change mermaid initialization to support code fences #6

This commit is contained in:
Sören Weber 2020-09-13 11:49:31 +02:00
parent b3429ed9a3
commit aad4bf26e1
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
2 changed files with 7 additions and 1 deletions

View file

@ -75,7 +75,9 @@
<script src="{{"mermaid/mermaid.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script> <script src="{{"mermaid/mermaid.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
{{ end }} {{ end }}
<script> <script>
mermaid.initialize({ startOnLoad: true }); if (mermaid) {
mermaid.startOnLoad = false;
}
</script> </script>
{{ end }} {{ end }}
{{ partial "custom-footer.html" . }} {{ partial "custom-footer.html" . }}

View file

@ -87,8 +87,12 @@ jQuery(document).ready(function() {
e.clearSelection(); e.clearSelection();
$(e.trigger).attr('aria-label', 'Link copied to clipboard!').addClass('tooltipped tooltipped-s'); $(e.trigger).attr('aria-label', 'Link copied to clipboard!').addClass('tooltipped tooltipped-s');
}); });
$('code.language-mermaid').each(function(index, element) { $('code.language-mermaid').each(function(index, element) {
var content = $(element).html().replace(/&amp;/g, '&'); var content = $(element).html().replace(/&amp;/g, '&');
$(element).parent().replaceWith('<div class="mermaid" align="center">' + content + '</div>'); $(element).parent().replaceWith('<div class="mermaid" align="center">' + content + '</div>');
}); });
if (mermaid) {
mermaid.init(undefined, $('.mermaid'));
}
}); });