Hexo 框架 LaTeX 数学公式支持解决方案
Hexo 框架 LaTeX 数学公式支持解决方案
问题描述
当前 Hexo 框架的默认 Markdown 渲染器不支持 LaTeX 数学公式语法,导致文章中的数学公式无法正确渲染显示。
解决方案概览
本文档提供三种主要解决方案:
- MathJax 集成方案(推荐)
- KaTeX 集成方案(性能更好)
- 更换渲染器方案(彻底解决)
方案一:MathJax 集成方案(推荐)
1.1 安装 hexo-math 插件
1 | npm install hexo-math --save |
1.2 配置 _config.yml
在站点根目录的 _config.yml 文件中添加:
1 | math: |
1.3 主题配置(以 Butterfly 主题为例)
在主题配置文件 _config.butterfly.yml 中添加:
1 | # Math (数学公式) |
1.4 文章头部配置
在需要使用数学公式的文章头部添加:
1 |
|
方案二:KaTeX 集成方案(性能更好)
2.1 安装 hexo-renderer-markdown-it-plus
1 | npm uninstall hexo-renderer-marked --save |
2.2 配置 _config.yml
markdown_it_plus:
highlight: true
html: true
xhtmlOut: true
breaks: true
langPrefix:
linkify: true
typographer:
quotes: '
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Ciallo~(∠・ω< )⌒☆!





