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
{{ message }}
Repository navigation
Commit 3792e19
Browse filesBrowse the repository at this point in the historyBrowse files
Each grammar costs every thread its own memory, about 60MB for
JavaScript's on Oniguruma, and time to register. Types and signatures
are already highlighted as TypeScript, whose grammar highlights
JavaScript too, so `js`, `mjs`, `cjs` and `javascript` code is now
highlighted with it by default, and C++ (`cpp`, `c++`) with C's. On
Node.js's docs that saves ~190MB of peak memory and 2-7% of build time.
In the light theme, the default, JavaScript comes out the same but for
one block of console output marked as `js`. Nord, the dark theme, has
a few colors only for JavaScript's scopes. C++-only keywords lose their
color.
`langAlias` and the languages in `langs` take precedence, and doc-kit
now resolves aliases itself: Shiki replaced configured aliases with a
grammar's own as it registered. Aliases now also lead on through other
aliases and are found in any case. Transformers, and the language
`resolveLanguage` returns, are the one code is highlighted as.
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Code is highlighted with fewer grammars by default, as each one takes its own memory on every thread: JavaScript (`js`, `mjs`, `cjs`, `javascript`) with TypeScript's grammar, which already highlights types, and C++ (`cpp`, `c++`) with C's. The Shiki plugin's `langAlias` option and the languages given in `langs` take precedence over these defaults, so `{ cpp: 'cpp', 'c++': 'cpp' }` brings back C++'s own grammar, and aliases now keep working once a grammar with the same aliases is registered. A highlighter's `resolveLanguage` now returns the language code is highlighted as, as its Shiki instance names it (`typescript` for `mjs`): highlight with what it returns. Transformers see that language too.
* @property {import('shiki').HighlighterCore} shiki - The Shiki instance
28
-
* @property {(languageId?: string) => string} resolveLanguage - Resolves a language, falling back to plain text for unknown ones
30
+
* @property {(languageId?: string) => string} resolveLanguage - Resolves the language code is highlighted as, falling back to plain text for unknown ones
29
31
* @property {(code: string, lang: string, meta?: Record<string, unknown>) => string} highlightToHtml - Highlights code, returning the inner HTML of its `<code>` element
30
32
* @property {(code: string, lang: string, meta?: Record<string, unknown>) => ReturnType<import('shiki').HighlighterCore['codeToHast']>} highlightToHast - Highlights code, returning a HAST tree
31
33
* @property {Array<Language>} langs - The languages it highlights
@@ -64,9 +66,6 @@ let engine;
64
66
// The highlighters of the options given, by their JSON
65
67
consthighlighters=newMap();
66
68
67
-
// What code in an unknown language is highlighted as
68
-
constFALLBACK_LANGUAGE='text';
69
-
70
69
// The languages Shiki bundles. Registering a grammar takes time and memory,
71
70
// and slows down every highlight after it, so each one is only imported and
72
71
// registered once code in it is highlighted (see `resolveLanguage`).
0 commit comments