Documentation
¶
Overview ¶
Package jsonhighlight tokenizes JSON for syntax highlighting.
It drives encoding/json/jsontext.Decoder once over the input, emitting one span per JSON token (string, number, literal, or structural delimiter) plus filler spans for inter-token bytes (commas, colons, whitespace). Object-key strings are distinguished from value strings via the decoder's stack-position state.
On parse error, spans for the prefix that decoded cleanly are returned; the unparsed remainder becomes a single CategoryPlain span. This mirrors gohighlight's degrade-gracefully approach so the editor never goes blank.
The output is a flat slice of byte-offset spans suitable for direct consumption by the codeview widget's retained CodeViewJob.Section calls. Output guarantees:
- Every byte of src is covered by exactly one span.
- For each span, src[Start:Stop] == Text and Stop-Start == len(Text).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var PackageProps = packageprops.Props{ WASMWASI: packageprops.WASMCompiles, WASMJS: packageprops.WASMCompiles, WASMFreestanding: packageprops.WASMCompiles, }
PackageProps records this package's curated properties (ADR-0080). Seeded by `boxer code analysis golang wasmsurvey props generate`; curate by hand. The same group's `props verify` reconciles it.
Functions ¶
This section is empty.
Types ¶
type CategoryE ¶
type CategoryE int
CategoryE classifies a span for highlighting.
const ( CategoryPlain CategoryE = iota // unclassified bytes (parse-error remainder) CategoryPunctuation // { } [ ] , : CategoryKey // object-member name (the "name" of "name":value) CategoryStringLit // string value CategoryNumberLit // number value CategoryBoolLit // true / false CategoryNullLit // null CategoryWhitespace // gaps between tokens (spaces, tabs, newlines) )