hexojs / hexo-renderer-markdown-it

Markdown-it is a Markdown parser, done right. A faster and CommonMark compliant alternative for Hexo.
MIT License
343 stars 60 forks source link

MathJax support #36

Closed wzpan closed 8 years ago

wzpan commented 8 years ago

Hello,

I'm looking for a light-weight but powerful npm markdown plugin and happend to see this one.

After giving it a try it looks the best for me. But the only problem I come across is that I'm not able to embeded MathJax just like what I did using hexo-renderer-marked or hexo-renderer-pandoc .

It seems that this is a missing feature of markdown-it . Have you ever tried to use MathJax with hexo-renderer-markdown-it ?

wzpan commented 8 years ago

with the help of this article I'm now able to write MathJax syntax now. Close this issue.

Digital2Slave commented 7 years ago

@wzpan could you please paste the steps for handle it.

wzpan commented 7 years ago
  1. install markdown-it-mathjax plugin for markdown it.
$ npm install markdown-it-mathjax --save 
  1. load mathjax in your layout files e.g.
<% if (page.math) { %>
<script type="text/x-mathjax-config">
   MathJax.Hub.Config({"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50) },
        tex2jax: { inlineMath: [ ["$", "$"], ["\\(","\\)"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno",skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']},
        TeX: {  noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } }, Macros: { href: "{}" } },
        messageStyle: "none"
    }); 
</script>
<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<% } %>