Butterfly代码块高亮踩坑

问题描述

代码块没有高亮,没有复制按钮,看起来简直就像是文本

解决路线

官方文档 - 代码高亮

issue 指路,也许有你需要的解答

首先查看hexo版本

1
heox --version

hexo: 7.2.0
hexo-cli: 4.3.2
os: win32 10.0.22631 undefined
node: 18.16.0
acorn: 8.8.2
ada: 1.0.4
ares: 1.19.0
brotli: 1.0.9
cldr: 42.0
icu: 72.1
llhttp: 6.0.10
modules: 108
napi: 8
nghttp2: 1.52.0
nghttp3: 0.7.0
ngtcp2: 0.8.1
openssl: 3.0.8+quic
simdutf: 3.2.2
tz: 2022g
undici: 5.21.0
unicode: 15.0
uv: 1.44.2
uvwasi: 0.0.15
v8: 10.2.154.26-node.26
zlib: 1.2.13

修改 hexo 的 _config.yml 配置

注意,是hexo的,不是主题的

如果是 7.0.0 以上

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# _config.yml
highlight:
enable: true
auto_detect: false
line_number: true
line_threshold: 0
tab_replace: ""
exclude_languages:
- example
wrap: true
hljs: false
prismjs:
enable: false
preprocess: true
line_number: true
line_threshold: 0
tab_replace: ""

如果是 7.0.0 以下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# _config.yml
syntax_highlighter: highlight.js
highlight:
auto_detect: false
line_number: true
line_threshold: 0
tab_replace: ""
exclude_languages:
- example
wrap: true
hljs: false
prismjs:
preprocess: true
line_number: true
line_threshold: 0
tab_replace: ""

踩坑路线

  1. 卸载了一些和代码块有关的插件 -> 没有解决问题
  2. 发现自己开启了阅读模式 -> 关闭阅读模式 -> 没有解决问题
  3. 发现自己没有清理浏览器缓存 -> 清理浏览器缓存 -> 没有解决问题
  4. 发现自己没有使用 hexo g -f 强制生成文件 -> 使用了,但没有解决问题
  5. 发现自己没有禁用hljs -> 禁用了,但没有解决问题