Hexo渲染LaTeX公式
Hexo添加mathjax
如果hexo安装有hexo-math,需要先卸载它。卸载命令:
1
npm uninstall hexo-math --save
安装mathjax,安装命令:
1
npm install hexo-renderer-mathjax --save
hexo主题开启mathjax,进入主题目录,编辑_config.yml,开启mathjax:
1
2
3
4# MathJax Support
mathjax:
enable: true
per_page: truehexo博客开启mathjax:博客文章的开头加入mathjax:true,具体如下:
1
2
3title: Hexo渲染LaTeX公式关键
date: 2020-09-30 22:27:01
mathjax: true
hexo切换kramed引擎
卸载marked引擎
1
2
3
npm uninstall hexo-renderer-marked --save安装kramed引擎
1
2
3
npm install hexo-renderer-kramed --save修改引擎bug:修改文件/node_modules\kramed\lib\rules\inline.js中escape和em两行,具体修改如下:
1
2
3
4
5
// escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
escape: /^\\([`*\[\]()#$+\-.!_>])/,
// em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
em: /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
修复Mixed Content的BUG
修改
./node_modules/hexo-renderer-mathjax/mathjax.html
1
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
改为
1
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>