Documentation
¶
Overview ¶
Package highlight wires Chroma syntax highlighting into the Markdown pipeline and generates the matching token stylesheet, so the parser and the template layer agree on a single theme without either owning Chroma.
Index ¶
- Constants
- func CSS(cfg config.CodeConfig) string
- func Enabled(cfg config.CodeConfig) bool
- func Extension(cfg config.CodeConfig) goldmark.Extender
- func Palette(cfg config.CodeConfig) (background, foreground string)
- func PanelDisabled(cfg config.CodeConfig) bool
- func Style(cfg config.CodeConfig) *chroma.Style
- func Themes() []string
Constants ¶
const ( // ThemeNone is the config value that turns syntax highlighting off while // keeping the code block panel style. ThemeNone = "none" // DefaultTheme is the theme used when the configured one is unknown to // Chroma, and the one config.Default() ships with. DefaultTheme = "monokai" // MonoFallbacks is the font stack appended after the configured code font, // so blocks still render as monospace when that font cannot be loaded. MonoFallbacks = `ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace` )
Variables ¶
This section is empty.
Functions ¶
func CSS ¶
func CSS(cfg config.CodeConfig) string
CSS returns the Chroma token stylesheet for cfg's theme, one rule per line, or "" when highlighting is off.
func Enabled ¶
func Enabled(cfg config.CodeConfig) bool
Enabled reports whether cfg asks for syntax highlighting.
func Extension ¶
func Extension(cfg config.CodeConfig) goldmark.Extender
Extension returns the goldmark extension that highlights fenced code blocks, or nil when highlighting is off. Token colors are emitted as classes rather than inline styles so CSS from the config keeps the last word.
func Palette ¶
func Palette(cfg config.CodeConfig) (background, foreground string)
Palette returns the code block background and foreground colors: explicit config values win, then the theme's own colors, then the fallbacks.
With the panel off, the theme's own text color is dropped unless it was set explicitly: it was picked to sit on the theme's background, not on the page.
func PanelDisabled ¶
func PanelDisabled(cfg config.CodeConfig) bool
PanelDisabled reports whether cfg turns the filled panel off, leaving code on the page background.
Types ¶
This section is empty.