highlight

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidStyle added in v0.15.0

func IsValidStyle(styleName string) bool

IsValidStyle reports whether styleName is a known Chroma style.

Types

type Highlighter

type Highlighter struct {
	// contains filtered or unexported fields
}

Highlighter applies syntax highlighting to source code lines using Chroma.

func New

func New(styleName string, enabled bool) *Highlighter

New creates a Highlighter with the given Chroma style name and enabled state. if styleName is empty, defaults to "monokai". Logs a warning if the style name is unknown.

func (*Highlighter) HighlightLines

func (h *Highlighter) HighlightLines(filename string, lines []diff.DiffLine) []string

HighlightLines takes a filename (for lexer detection) and a slice of diff.DiffLine, reconstructs the file content, tokenizes it with Chroma, and returns a parallel []string where each entry contains the ANSI-formatted (foreground-only) version of that line's content. returns nil if highlighting is disabled or no lexer matches the filename.

func (*Highlighter) SetStyle added in v0.15.0

func (h *Highlighter) SetStyle(styleName string) bool

SetStyle changes the Chroma style used for subsequent HighlightLines calls. Returns false if the style name is unknown.

func (*Highlighter) StyleName added in v0.15.0

func (h *Highlighter) StyleName() string

StyleName returns the current Chroma style name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL