package
Version:
v0.0.7
Opens a new window with list of versions in this module.
Published: Oct 5, 2026
License: AGPL-3.0
Opens a new window with license information.
Imports: 5
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
ui/highlight
代码高亮,可选模块。CodeEditor、TextView 和 Markdown 代码块的语法着色都来自这里;不引入时代码显示为纯文本,其他功能不受影响。
import _ "github.com/dyike/keel/ui/highlight"
- 为什么单独成包:它用 chroma,内置几百种语言的规则,在启动时全部注册,链接器删不掉,约占 4 MB。不显示代码的应用不必带上。
- 依赖:
ui/core(实现 core.Highlighter 并在 init 里 core.SetHighlighter)和 chroma。
- 语言名支持别名和扩展名(
go、golang、Go);配色默认 github / github-dark,按代码背景深浅选择,Markdown 可用 markdown.CodeStyle 指定 chroma 风格名。
要换别的高亮实现,实现 core.Highlighter 并调用 core.SetHighlighter。
Documentation
¶
Package highlight colors source code in CodeEditor, TextView and
Markdown code blocks. Import it for its side effect where the app shows
code:
import _ "github.com/dyike/keel/ui/highlight"
It is separate because its lexers (chroma, hundreds of languages) add
about 4 MB to a binary; without it code shows as plain text.
Chroma is the core.Highlighter this package installs.
Highlight tokenizes code; Style names a chroma style, defaulting to
github or github-dark.
Language is chroma's name for a language, alias or extension.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.