Documentation
¶
Overview ¶
Package syntax resolves language rules and highlights source text.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHighlighter ¶
func NewHighlighter(lexer chroma.Lexer, style *chroma.Style, observers ...func(chroma.Token)) func(string) []string
NewHighlighter reuses the selected lexer. Each call independently tokenises content and returns lines with ANSI styling. Observers receive every token of the pass, including errors before restyling and the final EOF. The caller must supply a non-nil style.
On tokenisation/formatting failure or a line-count mismatch, the result is unstyled strings.Split(content, "\n"), including any trailing empty element. Observers may already have received some or all tokens when this happens. Successful output omits the trailing empty element.
Types ¶
type Config ¶
type Config struct {
Aliases map[string]string `toml:"aliases" json:"aliases,omitempty"`
Files []FileType `toml:"files" json:"files,omitempty"`
}
func Merge ¶
Merge gives project aliases and filename rules precedence over global ones. Rules within each level keep their declaration order; the first match wins.
func (Config) ValidateNames ¶
ValidateNames catches ambiguous case variants before configuration levels merge.
type Rules ¶
type Rules struct {
// contains filtered or unexported fields
}
Rules is immutable after compilation and can be shared by concurrent renderers. A nil Rules value retains built-in language detection.