Documentation
¶
Overview ¶
Package syntax turns Chroma tokens into Scry-owned terminal styling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectLexer ¶
DetectLexer selects a lexer by path, old path, content sample, then fallback.
func HighlightLine ¶
HighlightLine highlights one diff body without using a cache.
func Highlightable ¶
Highlightable reports whether syntax highlighting should apply to a diff line.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache owns memoized syntax rendering for loaded patches.
func NewCache ¶
func NewCache(profiles ...terminal.ColorProfile) *Cache
NewCache creates an empty syntax cache.
type Highlighter ¶
type Highlighter struct {
// contains filtered or unexported fields
}
Highlighter wraps a coalesced Chroma lexer.
func NewHighlighter ¶
func NewHighlighter(path, oldPath, sample string, profiles ...terminal.ColorProfile) *Highlighter
NewHighlighter creates a highlighter using Scry's lexer detection order.
func (*Highlighter) Highlight ¶
func (h *Highlighter) Highlight(body string) string
Highlight renders body text with Scry-owned styles.
func (*Highlighter) HighlightSpan ¶
func (h *Highlighter) HighlightSpan(body string, start, end int) string
HighlightSpan renders body text and reverses the provided raw byte span.
type LineCache ¶
type LineCache struct {
// contains filtered or unexported fields
}
LineCache memoizes highlighted bodies by logical diff-line index.
func NewLineCache ¶
func NewLineCache(path, oldPath, sample string, profiles ...terminal.ColorProfile) *LineCache
NewLineCache creates a per-patch line highlighter.
func (*LineCache) HighlightLine ¶
HighlightLine returns the cached highlighted body for a diff line.