1. prism 更换代码块格式
1.1. 格式介绍
hexo 中支持 highlight.js 与 prismjs 两种代码高亮库
两种库的下载地址
hexo 切换代码高亮样式中, 在highlight与prism中进行切换
syntax_highlighter: prismjs
highlight:
enable: false
line_number: true
auto_detect: false
tab_replace: ''
wrap: true
hljs: false
prismjs:
enable: true
preprocess: true
line_number: true # 此处与下方的prism_plugin都需要开启
tab_replace: ''
prism_plugin:
mode: 'preprocess' # realtime/preprocess
theme: 'tomorrow' # 主题都行
line_number: true # default false
#如果为true就会显示代码号,而且会分两边显示,显得不友好
custom_css:
prism 较 highlight 更好用,以下介绍prism Hexo博客:六、prism代码高亮 - 简书
1.2. prism
从Prism下载样式
- 主题: 自行选择,plugin中自带主题
- 语言: 自行选择
- plugins: line_number 一定要选
将样式保存在
hexo-blog\themes\自己的主题\source\libs\prism\prism.js或使用 在head 和 footer 中增加js 与 css 的引用, 但是我没有成功,可能是主题不同,文件后缀不同导致