Skip to content

tokenClassName

function tokenClassName(category, prefix?): string;

Defined in: packages/engine/src/language/tokenClassName.ts:32

Maps a semantic category to a predictable, stable CSS class name.

Deliberately trivial: the category name IS the class-name key ("number"solve-number), so there is no separate table to keep in sync as categories grow. A brand-new category, including one contributed by a solve-js package at runtime, gets a matching class name with no changes here.

This is editor-agnostic on purpose. It produces a class-name string and nothing else, so it works the same whether the host is CodeMirror (Decoration.mark({ class: tokenClassName(token.category) })), Slate, ProseMirror, Monaco or a plain <span>. Actual colors are pure CSS, resolved from --solve-hl-{category} custom properties by each consumer.

ParameterTypeDefault valueDescription
categoryTokenCategoryundefinedSemantic category from getSemanticTokens().
prefixstringDEFAULT_TOKEN_CLASS_PREFIXNamespace to apply. Defaults to solve-.

string

The class name for that category.