#[non_exhaustive]pub enum Syntax {
Plain,
Keyword,
String,
Comment,
Constant,
Entity,
Variable,
Support,
}Expand description
What a run of source code is, once something has classified it.
The description carries the classification and never the source, which is
the whole of decision 19d7602d (2026-09-02, option d). An app that browses
source already has a lexer; a renderer does not and should not grow one, and
three renderers each growing their own would disagree about the same file.
§Why the app classifies and the renderer colours
Measured on MNW’s source browser, which is the only consumer in the tree. It highlights server-side with syntect and had already reduced syntect’s scope space to seven colours held fixed across all 31 themes, because a reader recognises a highlighting palette and re-tinting it per theme costs that recognition to gain nothing. So the classification existed on the app side already: the only question was whether to throw it away at the seam and have each renderer redo it. This is the answer.
The precedent is docengine’s Emphasis, which crosses the same seam the
same way: quasi-tui maps its four flags onto terminal modifiers, a webview
maps them onto elements, and neither parses markdown to do it.
§The eight, and why these eight
The seven MNW’s palette fixes, plus Plain for a run nothing
claimed. Plain is not an absence: a lexer that ran and found ordinary code
is saying something a renderer wants, and an Option<Syntax> would have made
“unclassified” and “not classified yet” one value.
#[non_exhaustive] from the first commit, deliberately. A ninth class is the
obvious next request and it must not be a breaking release across three
renderers and five apps.
§What it is not
A token type in a grammar. These are display classes, coarse on purpose:
the distinctions a reader uses at a glance, not the ones a parser makes.
A renderer wanting more has language on the node beside this and may do
whatever it likes with it.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Plain
Ordinary code nothing else claimed.
The default, and a real answer rather than a missing one. See the type’s
docs for why this is not an Option.
Keyword
A language keyword, and the storage and modifier words with it.
String
A string or character literal.
Comment
A comment.
Constant
A literal that is not a string: a number, a boolean, a constant name.
Entity
A name being defined: a function, a type, a module.
Variable
A name being used: a variable, a parameter, a field.
Support
Something the language or its library provides rather than this file.
Implementations§
Source§impl Syntax
impl Syntax
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
The stable lowercase name, for a renderer keying its own palette off it.
Named here rather than agreed between each renderer and each host, for
the reason every other spelling in this crate is: that is how one
renderer ends up calling it str and the next string, and a theme
written against one stops working under the other.
Not an Intent token, and the difference is worth stating. An intent
resolves against a makeover theme token, and there are none for syntax
colours: a highlighting palette is deliberately outside the theme, held
fixed while everything around it changes. So this is a name a renderer
maps however it can, and a renderer with no colours to spend maps every
one of them onto the same face and is not wrong.