Files
FWS-Kitty/tools/highlight/api.go
T
BlackAngelTV 7e7d249099 chore: import official kitty sources from upstream
Bring the kovidgoyal/kitty codebase in as the base of FWS-Kitty,
vendored at upstream commit 91fb38a without its git history.
2026-11-04 11:20:47 +01:00

33 lines
783 B
Go

package highlight
import (
"errors"
"fmt"
"github.com/alecthomas/chroma/v2"
"github.com/kovidgoyal/kitty/tools/utils"
)
var _ = fmt.Print
var ErrNoLexer = errors.New("No lexer available for this format")
type StyleResolveData interface {
StyleName() string
UseLightColors() bool
SyntaxAliases() map[string]string
TextForPath(string) (string, error)
}
type Highlighter interface {
HighlightFile(path string, srd StyleResolveData) (highlighted_string string, err error)
Sanitize(string) string
}
func NewHighlighter(sanitize func(string) string) Highlighter {
if sanitize == nil {
sanitize = func(text string) string { return utils.ReplaceControlCodes(text, " ", "\n") }
}
return &highlighter{sanitize: sanitize, tokens_map: make(map[string][]chroma.Token)}
}