书接Hexo-Next样式美化,本篇记录hexo-next组合对于
Latex渲染插件配置
具体的在theme-next Math docs中写的很清楚,有MathJax和Katex两种公式渲染方式。这里经过实际操作,选择MathJax。
安装hexo-renderer-pandoc,也尝试过hexo-renderer-kramed,但是没效果,具体愿意没有细察
1
2
3npm uninstall hexo-renderer-marked
npm install hexo-renderer-pandoc # or hexo-renderer-kramed
npm install hexo-filter-mathjax配置
next/_config.yml
, 打开mathjax
1
2
3
4math:
per_page: false
mathjax:
enable: true配置’hexo/_config.yml’ pandoc参数
mathjax参数1
2
3
4
5
6# config of hexo-renderer-pandoc
pandoc:
args:
- --mathjax # a must arg
# - --webtex # with it, each equation be in one line
# - --standalone # $...$ become \(\), but affect html styleNote 这里1
2
3
4
5
6
7
8
9mathjax:
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: {}every_page: false
,需要在文件头添加mathjax: true
CDN
1
2
3vendors:
# MathJax
mathjax: //cdn.jsdelivr.net/npm/mathjs@14.5.2/lib/browser/math.min.js生成,需要clean
1
2hexo clean && hexo g
# or hexo clean && hexo s示例
Github CI
hexo-renderer-pandoc依赖pandoc工具,在ci的环境中,需要系统安装了pandoc。在Hexo-Next搭建记录中ci脚本的基础上,修改相应的步骤。要是我自己写,可能要费点劲,还好有大佬做了相关的工作,Github Actions部署安装pandoc,拿来主义了,感谢分享。
添加安装pandoc的步骤
1
2- name: Install pandoc
run: curl -s -L https://github.com/jgm/pandoc/releases/download/2.18/pandoc-2.18-linux-amd64.tar.gz | tar xvzf - -C $RUNNER_TOOL_CACHE/生成步骤中,把pandoc的路径加入到环境变量
1
2
3
4
5- name: Build
run: |
# add pandoc to PATH
export PATH="$PATH:$RUNNER_TOOL_CACHE/pandoc-2.18/bin"
npm run build