mermaid and MathJax for Ghost

Header:

<script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML&delayStartupUntil=configured"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/knsv/mermaid/0.5.8/dist/mermaid.min.js"></script>
<script type="text/javascript">
    MathJax.Hub.Config({tex2jax: {inlineMath: [ ["$","$"] ], displayMath: [ ["$$", "$$"] ]}});
</script>
<script type="text/javascript">
        var postContents = document.getElementsByClassName('post-content');
        for(var i = 0; i < postContents.length; i++) {
            document.getElementsByClassName('post-content')[i].innerHTML = postContents[i].innerHTML.replace(/%%([\s\S]*)%%/g,'<div class="mermaid">$1</div>');
        }
        // document.getElementsByClassName('post-content')[0].innerHTML = document.getElementsByClassName('post-content')[0].innerHTML.replace(/%%([\s\S]*)%%/g,'<div class="mermaid">$1</div>');
        var mermaids = document.getElementsByClassName('mermaid');
        for(var i =0; i < mermaids.length; i++) {
            document.getElementsByClassName('mermaid')[i].innerHTML = mermaids[i].innerHTML.replace(/<\/?[\s\S]*>/g, '');
        }
        MathJax.Hub.Configured();
        mermaid.initialize({startOnLoad:true});
    </script>
Show Comments