highlight

package
v0.8.0 Latest Latest
Warning

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

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

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.

Jump to

Keyboard shortcuts

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