prism 更换代码块格式


1. prism 更换代码块格式

1.1. 格式介绍

hexo 中支持 highlight.jsprismjs 两种代码高亮库

两种库的下载地址

  1. highlight
  2. Prism

hexo 切换代码高亮样式中, 在highlightprism中进行切换

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

  1. Prism下载样式

    1. 主题: 自行选择,plugin中自带主题
    2. 语言: 自行选择
    3. plugins: line_number 一定要选
  2. 将样式保存在hexo-blog\themes\自己的主题\source\libs\prism\prism.js

    或使用 在head 和 footer 中增加js 与 css 的引用, 但是我没有成功,可能是主题不同,文件后缀不同导致


文章作者: 小白菜
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 小白菜 !
评论
  目录