Versions in this module Expand all Collapse all v1 v1.0.1 Jun 27, 2026 v1.0.0 Jun 24, 2026 Changes in this version + const ColorDepth16 + const ColorDepth256 + const ColorDepth8 + const ColorDepthTruecolor + var ErrGrammarCycle = grammar.ErrGrammarCycle + var ErrGrammarDepth = grammar.ErrGrammarDepth + var ErrLanguageNotFound = registry.ErrLanguageNotFound + var ErrThemeNotFound = registry.ErrThemeNotFound + var Lines = ast.Lines + var NewStyleClassMap = ast.NewStyleClassMap + var Range = ast.Range + type BaseTransformer = ast.BaseTransformer + type CodeToANSIOptions = ast.CodeToANSIOptions + type CodeToHTMLOptions = ast.CodeToHTMLOptions + type CodeToJSONOptions = ast.CodeToJSONOptions + type CodeToPlainTextOptions = ast.CodeToPlainTextOptions + type CodeToSVGOptions = ast.CodeToSVGOptions + type CodeToTokensOptions = ast.CodeToTokensOptions + type ColorDepth = ast.ColorDepth + type Diagnostic = ast.Diagnostic + type Element = ast.Element + type Highlighter struct + func New(ctx context.Context, opts ...Option) (*Highlighter, error) + func (h *Highlighter) Close(ctx context.Context) error + func (h *Highlighter) CodeToANSI(ctx context.Context, code string, opts ast.CodeToANSIOptions) (string, error) + func (h *Highlighter) CodeToHTML(ctx context.Context, code string, opts ast.CodeToHTMLOptions) (string, error) + func (h *Highlighter) CodeToHighlightedTokens(ctx context.Context, code string, opts ast.CodeToTokensOptions) (*ast.TokensResult, error) + func (h *Highlighter) CodeToJSON(ctx context.Context, code string, opts ast.CodeToJSONOptions) ([]byte, error) + func (h *Highlighter) CodeToPlainText(ctx context.Context, code string, opts ast.CodeToPlainTextOptions) (string, error) + func (h *Highlighter) CodeToSVG(ctx context.Context, code string, opts ast.CodeToSVGOptions) (string, error) + func (h *Highlighter) CodeToTokens(ctx context.Context, code string, opts ast.CodeToTokensOptions) (*ast.TokensResult, error) + func (h *Highlighter) DetectLanguage(filename string) (string, bool) + func (h *Highlighter) DetectLanguageByContent(firstLine string) (string, bool) + func (h *Highlighter) GetThemeColors(themeName string) (ThemeColors, error) + func (h *Highlighter) LoadLanguage(name string, data []byte) error + func (h *Highlighter) LoadTheme(name string, data []byte) error + func (h *Highlighter) LoadedLanguages() []string + func (h *Highlighter) LoadedThemes() []string + func (h *Highlighter) RegisterAlias(alias, target string) + func (h *Highlighter) RegisterExtension(ext, lang string) + type LineRange = ast.LineRange + type Node = ast.Node + type Option func(*options) + func WithAlias(alias, target string) Option + func WithCompilationCacheDir(dir string) Option + func WithDefaults(defaults CodeToHTMLOptions) Option + func WithExtension(ext, lang string) Option + func WithFS(fsys fs.FS) Option + func WithGrammar(name string, data []byte) Option + func WithGrammarFS(fsys fs.FS) Option + func WithMaxLineLength(n int) Option + func WithMinContrast(ratio float64) Option + func WithPoolSize(n int) Option + func WithRegexInterruption(enabled bool) Option + func WithTheme(name string, data []byte) Option + func WithThemeFS(fsys fs.FS) Option + func WithTimeoutMs(ms int) Option + type StyleClassMap = ast.StyleClassMap + type Text = ast.Text + type ThemeColors = ast.ThemeColors + type ThemedToken = ast.ThemedToken + type TokenStyle = ast.TokenStyle + type TokensResult = ast.TokensResult + type Transformer = ast.Transformer