1. prism.js

1.1. Disable Highlight.js

  • antora默认使用highlight.js,antora-playbook.yml做如下配置

  • antora只支持js高亮,source-highlighter: ~

asciidoc:
  sourcemap: true
  attributes:
    # source-highlighter: highlight.js
    source-highlighter: ~

1.2. Download Prism.js

Type Memo

Common

  • Markup + HTML + XML + SVG + MathML + SSML + Atom + RSS

Frontend

  • TypeScript,JavaScript,Css,WebAssembly

Backend

  • Java,Go,Rust,Ruby,Python,C,C#,C++,Groovy,C-like

Config

  • Properties,Ini,Yaml,Toml,Gradle

Script

  • CMake,Bash + Shell + Shell,PowerShell,Makefile

AI Math

  • LaTeX + TeX + ConTeXt,Matlab

  • Wolfram language + Mathematica + Mathematica Notebook

Doc

  • AsciiDoc,Markdown,Dot(Graphviz),PlantUML

Query Language

  • SQL,PromQL,GraphQL,MongoDB

Rare

  • Git,,Docker,Protocol Buffer

2. Config Prism

  • 下载Prism后取名prism-1.29.0-coy.js和prism-1.29.0-coy.css

# footer-scripts.hbs添加
<script async src="{{{uiRootPath}}}/js/vendor/prism-1.29.0-coy.js"></script>

# head-styles.hbs添加
<link rel="stylesheet" href="{{uiRootPath}}/css/vendor/prism-1.29.0-coy.css">

3. highlight.js

3.1. Install Highlight.js

npm install highlight.js -g
  • Antora在AsciiDoc处理器默认使用highlight.js高亮代码块;

  • 要禁用(turn off )syntax highlighting:

asciidoc:
  attributes:
    source-highlighter: ~

* 若改为软取消设置(soft unset),如值设置为false,
则允许各页面选择性的重新打开(turn on)syntax highlighting;

  • 默认:Antora会高亮显示一组受限制的语言,以最大限度地减小支持资产文件的大小,
    可在自己的UI Bundle添加或删除对语言的支持,具体执行以下步骤:

3.2. Regist Highlight

  • src/js/vendor/highlight.bundle.js,增删registerLanguage语句,如:

hljs.registerLanguage('asciidoc',require('highlight.js/lib/languages/asciidoc'))
hljs.registerLanguage('bash', require('highlight.js/lib/languages/bash'))
hljs.registerLanguage('shell', require('highlight.js/lib/languages/shell'))
hljs.registerLanguage('sql', require('highlight.js/lib/languages/sql'))
hljs.registerLanguage('protobuf', require('highlight.js/lib/languages/protobuf'))
hljs.registerLanguage('ini', require('highlight.js/lib/languages/ini'))
hljs.registerLanguage('rust', require('highlight.js/lib/languages/rust'))
hljs.registerLanguage('java', require('highlight.js/lib/languages/java'))
hljs.registerLanguage('python', require('highlight.js/lib/languages/python'))
hljs.registerLanguage('groovy', require('highlight.js/lib/languages/groovy'))
hljs.registerLanguage('javascript', require('highlight.js/lib/languages/javascript'))
hljs.registerLanguage('ini', require('highlight.js/lib/languages/ini'))
hljs.registerLanguage('properties', require('highlight.js/lib/languages/properties'))
hljs.registerLanguage('gradle', require('highlight.js/lib/languages/gradle'))
hljs.registerLanguage('json', require('highlight.js/lib/languages/json'))
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'))
hljs.registerLanguage('yaml', require('highlight.js/lib/languages/yaml'))
hljs.registerLanguage('dockerfile', require('highlight.js/lib/languages/dockerfile'))
hljs.registerLanguage('css', require('highlight.js/lib/languages/css'))

3.3. Highlight Css Recommendation

atelier-dune,unikitty-light,macintosh,green-screen,
vs,google-light,marrakesh,papercolor-dark,github-new,
cupertino,atelier-forest-light,material-vivid,one-light,
1c-light,fruit-soda,dirtysea,github,gradient-light,pico,
papercolor-light,nnfx-light,xcode,equilibrium-gray-light,
stackoverflow-light,ia-light,intellij-light,atelier-cave,
summerfruit-light,atelier-dune-light,atelier-seaside-light,
harmonic16-light,panda-syntax-light,atelier-sulphurpool-light,
paraiso,brogrammer,humanoid-light,atom-one-light,atelier-forest,