Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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.
Click to show internal directories.
Click to hide internal directories.