You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CSS, Go, HTML, Java, JavaScript, TypeScript, Python and Rust are
highlighted by a port of CodeMirror's own Lezer parser. A file of one of
them is parsed with its @lezer/* grammar and tagged by its styleTags, as
CodeMirror tags it: a call and a declaration, a type and a variable, are told
apart where chroma could not, and HTML's scripts, styles and style/on*
attributes are highlighted as JavaScript and CSS. Code a grammar cannot
parse is left as CodeMirror leaves it.
Kotlin and shell scripts are highlighted as CodeMirror highlights them,
by a port of the @codemirror/legacy-modes modes (kotlin, shell) that
CodeMirror runs through its StreamLanguage: .kt, .kts, .sh, .ksh, .bash and a file named PKGBUILD. Every other language is still read by
chroma.
New content in a Lezer language is reparsed incrementally.SetContent
and UpdateContent reuse the tree of the content before, as CodeMirror
reparses after an edit, nested scripts and styles included: a one-character
edit to 13,000 lines of Java reparses in about 1.2 ms instead of 50 ms, and
the whole update takes about 28 ms instead of 78; in a 13,000-line HTML page,
0.4 ms instead of 71, and 30 ms instead of 102. Highlighting now runs one
content at a time, in order, skipping one replaced before its turn.
A token can carry several tags, and its style merges theirs. Each tag
takes the spec of its most specific styled tag, and the specs apply in
their order in the HighlightStyle, a later one's color, bold, italic,
underline or line-through winning, as CSS cascades CodeMirror's classes. A
chroma token still has one tag, and draws as before.