174 字
1 分钟
在Hexo中启用新Markdown解释器并配置Katex
Markdown编译器
在 Hexo 中,如果默认的 Markdown 编译器无法正确渲染 LaTeX 公式,可以考虑使用支持 LaTeX 公式的 Markdown 编译器插件。常用的包括:
- hexo-renderer-pandoc
- hexo-renderer-markdown-it
- hexo-filter-mathjax
- hexo-renderer-markdown-it-plus
hexo-renderer-markdown-it-plus 安装与配置
- 卸载旧的渲染器:
npm uninstall hexo-renderer-marked --save- 安装
hexo-renderer-markdown-it-plus:
在Hexo根目录中打开Git Bash,然后:
npm install hexo-renderer-markdown-it-plus --save- 配置
_config.yml:
添加以下配置:
markdown: render: engine: markdown-it-plus options: html: true xhtmlOut: true breaks: true linkify: true typographer: true quotes: '“”‘’' plugins: - plugin: name: markdown-it-katex options: throwOnError: false errorColor: '#cc0000'引入KaTeX的CSS
为了避免公式错位问题,需要确保正确引入 KaTeX 的 CSS 文件。在主题布局文件(通常是 themes/your-theme/layout/_partial/head.ejs)中添加以下代码:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css"> 在Hexo中启用新Markdown解释器并配置Katex
https://arkmostima.pages.dev/posts/在hexo中启用新markdown解释器并配置katex/