Code Grammars

Declarative syntax-highlighting grammars for fenced code blocks in Markdown prose. A CodeGrammar is an ordered list of token rules (a regex paired with a TokenClass); the SDK ships one generic scanner that applies them, so a publisher adds a new language by authoring a grammar here rather than changing renderer code. Token colors are a theme concern and live in the look stylesheet.

Highlighting is split three ways so each layer stays in its proper home. The mechanism is a single language-neutral scanner in the SDK: given an ordered rule list it walks the source left to right, first match wins, emitting a kan-tok-<class> span per token. The intent is declarative and lives here — each Code Grammar names a fence language and lists Token Rules, each pairing a regex pattern with a Token Class (the shared categories themes target, like Keyword or String). The theme — which color each TokenClass renders in — is CSS in the look stylesheet. Ships grammars for YAML and Bash; bring another language (C#, SQL, …) by publishing a CodeGrammar in your own package, no SDK change.

BashBooleanBoolean / null-like keywords.Code GrammarA syntax-highlighting grammar for one fenced-code language: a `language` tag (matched against the fence info string) plus an ordered list of token `rule`s…CommentComments and documentation.FlagCommand-line flags / options.KeyMapping keys / property names.KeywordLanguage keywords.LanguageThe fence info string this grammar highlights, e.g. "yaml" for a ```yaml block. Matched verbatim against the fence's first word.NumberNumeric literals (including dotted versions).OperatorOperators and pipes.PatternA JavaScript-flavored regular expression, applied anchored (sticky) at the current scan position. Plain data, not a Kanonak reference.PunctuationStructural punctuation.RuleThe grammar's token rules, applied in list order, first match wins.StringString and quoted literals.Token ClassA token category that themes color. The class's name becomes the CSS class on the emitted span (`kan-tok-<name>`), so the look stylesheet can style all…Token ClassThe TokenClass a rule paints when its pattern matches.Token RuleOne highlighting rule — a regex `pattern` and the `tokenClass` it paints when matched at the current scan position. Rules are applied in list order; the first…YAML