Documentation
¶
Overview ¶
Package highlight provides syntax highlighting for English source code.
It exposes two main entry points:
- Highlight(source, useColor) – colour an entire source file
- HighlightInline(text, useColor) – highlight English code snippets embedded inside prose text (e.g. error-message hints that contain single-quoted examples like `'Declare x to be 5.'`)
When useColor is false both functions return plain text with no ANSI codes.
Both functions use the shared tokeniser package so that keyword recognition, multi-word operators, possessive handling, and every other tokenisation rule are identical to those used by the actual compiler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Highlight ¶
Highlight returns source with ANSI syntax highlighting applied when useColor is true. If the source contains unrecognised characters the remainder is coloured in a dim grey so that as much as possible is highlighted while invalid sections are still clearly distinguishable.
func HighlightInline ¶
HighlightInline scans text for English code snippets delimited by single quotes (e.g. the hint strings produced by parser/messages.go) and applies syntax highlighting to each snippet. Surrounding prose is returned unchanged.
When useColor is false the text is returned unmodified.
Types ¶
This section is empty.