在markdown中书写数学符号的方式参考Latex常用数学符号

Mathjax

安装

npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --save

修改

打开node_modules/hexo-renderer-kramed/lib/renderer.js,将

// Change inline math rule
function formatText(text) {
    // Fit kramed's rule: $$ + \1 + $$
    return text.replace(/`\$(.*?)\$`/g, '$$$$$1$$$$');
}

改为:

// Change inline math rule
function formatText(text) {
    return text;
}

卸载

npm uninstall hexo-math --save

安装

npm install hexo-renderer-mathjax --save

修改

打开node_modules/hexo-renderer-mathjax/mathjax.html,将 <script> 改为:

<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>

打开node_modules/kramed/lib/rules/inline.js:

首先将

escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,

改为:

escape: /^\\([`*\[\]()# +\-.!_>])/,

然后将

em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,

改为:

em: /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,

开启公式支持功能

home/_config.yml,中添加如下内容

mathjax:
    enable: true

相关文章:

  • 2021-12-02
  • 2021-08-20
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2021-10-22
  • 2022-12-23
猜你喜欢
  • 2021-07-31
  • 2021-09-18
  • 2022-12-23
  • 2021-05-24
  • 2021-11-08
相关资源
相似解决方案