Documentation
¶
Overview ¶
Package syntax is a tiny, dependency-free syntax highlighter for the TUI previews. It tokenises source into per-line coloured Spans; the caller maps each Span's Kind to a terminal colour.
Rather than hand-roll a Go lexer (or pull in a heavyweight highlighter such as github.com/alecthomas/chroma, whose transitive deps would break this repo's dependency-free axiom), the Go path reuses the standard library's go/scanner -- the canonical Go tokeniser, zero extra dependencies. Markdown and the plain fallback are trivial line passes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Kind ¶
type Kind int
Kind categorises a run of source text.
const ( // Plain is uncoloured text (identifiers, whitespace, operators left in the // foreground colour). Plain Kind = iota // Keyword is a language keyword (Go's `func`; a Markdown heading line). Keyword // String is a string / rune / raw-string literal. String // Comment is a line or block comment. Comment // Number is a numeric literal. Number // Type is a predeclared type name (int, string, …). Type // Func is an identifier used as a call (immediately followed by "("). Func // Punct is a bracket / operator / separator. Punct )
Click to show internal directories.
Click to hide internal directories.