这玩意儿曾经让我头疼,现在不疼了。
一、安装 Pandoc
访问 Pandoc-Installing pandoc 下载安装,或者使用 Win-get:
winget install --source winget --exact --id JohnMacFarlane.Pandoc二、更换渲染引擎
- 卸载 hexo-renderer-marked 和 hexo-math
npm uninstall hexo-math --save
npm uninstall hexo-renderer-marked --save
- 安装 hexo-renderer-pandoc 和 hexo-filter-mathjax
npm install hexo-renderer-pandoc --save
npm install hexo-filter-mathjax --save三、修改配置
打开 Hexo 根目录的 _config.yml 文件,添加下面的代码:
mathjax:
tags: none # or 'ams' or 'all'
single_dollars: true # enable single dollar signs as in-line math delimiters
cjk_width: 0.9 # relative CJK char width
normal_width: 0.6 # relative normal (monospace) width
append_css: true # add CSS to pages rendered by MathJax
every_page: false # if true, every page will be rendered by MathJax regardless the `mathjax` setting in Front-matter
packages: # extra packages to load
extension_options: {}
# you can put your extension options here
# see http://docs.mathjax.org/en/latest/options/input/tex.html#tex-extension-options for more detail
此配置来自 hexo-filter-mathjax。
四、重新构建
hexo clean
hexo g
可能会遇到 pandoc exited with code null 的报错,此时重启一遍电脑就(可能)会好,原因未知。
五、其他
我之前是把 Hexo 项目 push 到 GitHub,再由 Cloudflare Workers 自动构建发布。现在需要用到本地的 Pandoc,Cloudflare 显然办不到。
我现在会在本地生成静态网页,然后在 Cloudflare Workers 设置“构建输出目录”为 /public 。