Skip to content

react-shiki@0.11.1

Choose a tag to compare

@github-actions github-actions released this 11 Aug 23:20
· 16 commits to main since this release
4f04b1f

Patch Changes

  • Fix: case-insensitive matching for language aliases. #184 2484f24 @aouxwoux

  • Fix(css): three default-style selectors left part of the selector outside :where() (pre, language label, highlighted line), giving them real specificity that could tie with or beat user rules depending on stylesheet order. All selectors are now fully wrapped and zero-specificity, so any user rule always wins. #185 607be76 @AVGVSTVS96

  • Feat: preloadLanguages now accepts dynamic grammar imports (shiki's LanguageInput) on the full and web bundles, so custom grammars can stay code-split instead of shipping in the main bundle: #193 530d033 @AVGVSTVS96

    const preload = [() => import("../langs/mcfunction.tmLanguage.json")];
    
    <ShikiHighlighter language="mcfunction" preloadLanguages={preload}>
      {code}
    </ShikiHighlighter>;

    Promises, getters, and module objects are all accepted and resolved by shiki during highlighter setup. Define them at module scope, preferring the getter form: a fresh arrow function on every render re-triggers highlighting, while swapping a bare promise at runtime is not detected. Additive only: strings and grammar objects work exactly as before.

  • Feat: add named engines. engine now accepts 'javascript' or 'oniguruma' alongside engine instances. #192 5f94c02 @AVGVSTVS96

    • Named engines are created, cached, and lazy-loaded internally; 'javascript' skips the WASM fetch entirely
    • Referentially stable, so safe to pass inline without re-triggering highlighting on rerenders
    • Engine instances are still accepted for custom configuration; create them once at module scope

    Heads up: the next minor release will swap the default engine from Oniguruma WASM to the JavaScript engine (with forgiving enabled by default, see shiki/regex-engines).

  • Fix: removed the hardcoded id="language-label" from the language label. Pages with multiple code blocks rendered duplicate ids (invalid HTML, and getElementById only ever found the first label). Style the label with the .rs-language-label class or [data-slot="language-label"] instead of #language-label. #190 9b73990 @AVGVSTVS96

  • Fix: styles are embedded in the JS and install automatically at runtime (as before 0.10.0), no CSS import or bundler configuration needed. Fixes styles dropped from webpack production builds, ERR_UNKNOWN_FILE_EXTENSION crashes in plain Node ESM, and broken no-bundler/CDN usage. react-shiki/css still exports the complete compiled stylesheet for build-time CSS pipelines. #188 6ef68a3 @AVGVSTVS96