hexo的一些配置

Blog使用的主题为NextT,使用文档请参考http://theme-next.iissnan.com/

Mathjax公式支持

使用hexo-math插件支持,github link: https://github.com/akfish/hexo-math

安装方法:

1
npm install hexo-math --save

在博客的_config.yml文件中加入

1
2
3
4
5
6
7
8
9
10
11
math:
engine: 'mathjax' # or 'katex'
mathjax:
src: custom_mathjax_source
config:
# MathJax config
katex:
css: custom_css_source
js: custom_js_source # not used
config:
# KaTeX config

使用方法就是$inline$$$block$$,也有tag用法,参见项目的帮助文件

重要的问题来了,hexo会把_markded.js渲染下回被escape掉并被替换为<em>标签,即斜体字,\\也会被转义为一个\

改进的方法:

  1. 用编辑器打开marked.js,路径为.\node_modules\hexo-renderer-marked\node_modules\marked\lib,如果找不到,可以在blog目录下search一下

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

    替换为

    1
    escape: /^\\([`*\[\]()# +\-.!_>])/,
  3. 1
    em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,

    替换为

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