每当在一些markdown编辑器写完文章后,由于常用到LaTeX要用到大量下划线,所以在发文章前要在文章所有下划线前加反斜杠才不会乱。这样hexo的md就和所写的纯md不一样了。
hexo自带的markdown渲染引擎对于一些复杂的公式无法支持渲染,这让我很头疼,写好的公式还要截成图才能发布。如何使用其他的markdown渲染引擎?
阿神2017-04-17 13:04:13
Thank you h404bi for your answer. This pitfall has been around for a long time. Now I’ll fix it...
Mainly the articles edited on some md editors are pasted to hexo. If {% raw %}{% endraw %}
is added, it will be different from the original article. It needs to be modified every time it is published =_= Later I found a way to directly modify the Markdown Content:
The conflict is mainly caused by escaping of and _. Find the marked script file, usually in
hexo\node_modules\marked\lib\marked.js
Back up first, then modify line 449
escape: /^\([\`*{}\[\]()#+\-.!_>])/,
is
escape: /^\([`*\[\]()#+\-.!_>])/,
Line 847
return '<em>' + text + '</em>';
was changed to:
return '_' + text + '_';
Not recommended, but this is how I solved it so far.
巴扎黑2017-04-17 13:04:13
The default selection of Hexo is Markdown and the rendering engine is marked (hexo-renderer-marked).
In addition to the default marked, other good Markdown rendering engines currently available on Hexo and still being maintained include hexo-renderer-markdown-it and hexo-renderer-pandoc, of which the former markdown-it supports CommonMark
standard, the latter supports Pandoc
(markup language converter, I haven’t used it, but after looking at it, it seems to support LaTeX to HTML).
If you want to write formulas, you can try MathJax. The MathJax renderer is also implemented on Hexo. Google for details: Hexo MathJax.
How to use other Markdown rendering engines. Just replace the Markdown renderer dependency of package.json
in hexo, for example, replace hexo-renderer-marked
with hexo-renderer-markdown-it
.
By the way, if you want to avoid underscores and backslashes, you can try the Tag Plugins that come with Hexo. Content within {% raw %}{% endraw %}
will not be rendered.