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.