Skip to content

This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.

createTokenClassName

function createTokenClassName(prefix): (category) => string;

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

Builds a tokenClassName bound to a fixed prefix.

The prefix is configurable because a host may already own a namespace it wants these classes to sit inside: a CodeMirror theme that keys off cm-, a design system that scopes everything under one token, or an app that embeds two editors and wants to style them apart. Passing the prefix once here is cheaper than threading it through every call site.

const className = createTokenClassName("cm-solve-");
className("number"); // "cm-solve-number"
ParameterTypeDescription
prefixstringNamespace to apply to every category.

A function mapping a category to a prefixed class name.

(category) => string