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
-
选择对应的主题Theme(推荐coy和default)和高亮的语言列表;
Type | Memo |
---|---|
Common |
|
Frontend |
|
Backend |
|
Config |
|
Script |
|
AI Math |
|
Doc |
|
Query Language |
|
Rare |
|
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'))
-
另需highlight.js支持相对应的语言,具体参考github:
3.3. Highlight Css Recommendation
atelier-dune,unikitty-light,macintosh,green-screen, |