Hexo: Bug:marked 和 Mathjax冲突

Created on 12 Mar 2014  ·  16Comments  ·  Source: hexojs/hexo

你好! 默认的markdown解析器会把公式里的一些字符转义,导致mathjax无法解析。不知道能否更换markdown解析器?

question

Most helpful comment

这个问题是由Hexo自带的Markdown渲染引擎和MathJax冲突引起的,解决方法很简单。更换Markdown渲染引擎就可以了。详细可以查看我的博文

This issue is caused by the conflict of hexo-renderer-marked(Hexo's default Markdown renderer) and MathJax. To fix this issue, you can simply change your markdown renderer. See the detail in my blog.

All 16 comments

附上latex代码:
$$ \int _ \Omega f\nabla \cdot \boldsymbol{A} d\Omega+\int _ \Omega$$
两个下划线被转移成斜体

试试rawblock

 {% rawblock %}
$$ \int _ \Omega f\nabla \cdot \boldsymbol{A} d\Omega+\int _ \Omega$$
 {% endrawblock %}

没遇过这类问题。建议:

1) 在引入 mathjax 前,先进行设置:

<script type="text/x-mathjax-config">
       MathJax.Hub.Config({
            tex2jax: {
                inlineMath: [["\\(", "\\)"]],
                displayMath: [["\\[", "\\]"]]
            }
        });
    </script>
    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

2) 如果无法解决,可以更换 markdown 解析器。我个人推荐使用语法更strong的 pandoc-markdown ,hexo下可使用 hexo-renderer-pandoc

使用rawblock可以解决大多数因为特殊符号导致的渲染问题。
@wzpan pandoc虽然是神器,但是不太会用= =。在hexo下面使用是不是还要再进行额外的配置?
@maplewizard 要是问题解决了就关闭issues,要是没有解决,请继续反馈。

不需要额外配置。看pandoc官方文档学习pandoc-markdown语法即可,与markdown大同小异。

please close this issue

给了一个利用 JS 解决问题的办法:
http://liam0205.me/2015/09/09/fix-conflict-between-mathjax-and-markdown/

我从别处看来的一个办法:http://kubicode.me/2016/03/16/Hexo/Fix-Hexo-Bug-In-Mathjax/

不过这个办法还是有问题,就是
\begin{equation*}\end{equation*}。这两个*会被处理成<em>

可以更换markdow解释器,使用pandoc,可以几乎完美解决问题,https://tveek.github.io/2016/08/27/octopress-hexo-learning-experience/

这个问题是由Hexo自带的Markdown渲染引擎和MathJax冲突引起的,解决方法很简单。更换Markdown渲染引擎就可以了。详细可以查看我的博文

This issue is caused by the conflict of hexo-renderer-marked(Hexo's default Markdown renderer) and MathJax. To fix this issue, you can simply change your markdown renderer. See the detail in my blog.

比较直接的方法,就是修改Hexo的渲染机制, node_modules/marked/lib/marked.js里面的_的转义,也很简单,改两行就可以了。具体参考

➜ blog hexo g
INFO Start processing
events.js:160
throw er; // Unhandled 'error' event
^

Error: write EPIPE
at exports._errnoException (util.js:1022:11)
at WriteWrap.afterWrite [as oncomplete] (net.js:804:14)

hexo-renderer-pandoc 无法使用,pandoc 我已经安装好了

➜ blog pandoc --version
pandoc 2.0.2
Compiled with pandoc-types 1.17.3, texmath 0.10, skylighting 0.4.3.2
Default user data directory: /Users/liuqinh2s/.pandoc
Copyright (C) 2006-2017 John MacFarlane
Web: http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.

@liuqinh2s 看错误信息我也不清楚,不过可以试试先hexo clean 再hexo g. 然后就是需要先卸载原生的mark然后在用pandoc, 我按照我笔记里面的来的,http://shomy.top/2016/10/22/hexo-markdown-mathjax/

原生的那个 hexo-renderer-marked 我卸载了,没有用的,我用的是 mac os x 系统

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hjmJhon picture hjmJhon  ·  3Comments

jo4x962k7JL picture jo4x962k7JL  ·  3Comments

yunTerry picture yunTerry  ·  3Comments

awulkan picture awulkan  ·  3Comments

mashirozx picture mashirozx  ·  3Comments