v1.0.0
Shiki v1.0 is a major rewrite that solves most of the long-lasting issues. Previously known as Shikiji, now it's merged back to Shiki.
Notable Highlights
- Full ESM support, no static assets or CDN settings are needed anymore
- No filesystem dependencies, platform agnostic, works for Node.js, browsers, and any other modern runtime out-of-box.
- Dual themes built-in, to support Light/Dark modes efficiently
- Transformers & Decorations API, maximize the customizability
- Official rehype and markdown-it plugin
- TwoSlash integration is now a Shiki transformer instead of a wrapper
- More themes and better language support. Maintained as a standalone repo: https://github.com/shikijs/textmate-grammars-themes
- New docs: https://shiki.style
Generated Changelog
🚨 Breaking Changes
- Flat lang registration - by @antfu (d7f66)
- Shorten
languages/
tolangs/
- by @antfu (2f4fe) - Change
codeToThemedTokens
options - by @antfu (5d8cf) - Rename
codeToHtmlDualThemes
tocodeToHtmlThemes
- by @antfu (57daa) - Use hast, unify
codeToHtmlThemes
tocodeToHtml
- by @antfu in #9 (26cd5) - Rework
hastTransform
totransforms
- by @antfu (3d245) - Improve return type of
codeToTokensWithThemes
, close #37 - by @antfu in #37 (3acf1) - Add
unwasm
condition in exports - by @antfu in #72 (96300) - Remove deprecated APIs - by @antfu in #75 (97c96)
- Consistent case of
Twoslash
- by @antfu (f740b) - Rename to shiki - by @antfu (a04b3)
- Remove renderers - by @antfu (718b0)
- Merge Shikiji back into Shiki for v1.0 - by @antfu (c72a5)
- Remove all deprecated APIs - by @antfu (1a39f)
- Refactor internal context - by @antfu (5ba2a)
- core:
- markdown-it:
- rehype:
- twoslash:
- Improve rich renderer - by @antfu in #41 (0bd42)
- Move to
twoslash
package for better performance and composablity - by @antfu in #91 (fc67e) - Rename renderer hook
nodeCompletions
tonodeCompletion
- by @antfu (b7637) - Support highlight - by @antfu (1ebe8)
- Fix highlight typos - by @jxom in #102 (b8c4c)
🚀 Features
- Rewrite from shiki - by @antfu (c14ed)
- Types for each export - by @antfu (1ffb6)
- Improve types - by @antfu (762d5)
- Auto module
default
resolution - by @antfu (de847) - Improve module resolution - by @antfu (fa20a)
- Bundle include embedded languages - by @antfu (7e85d)
- Provide singleton shorthands - by @antfu (e00df)
- Add
codeToHtmlDualThemes
- by @antfu in #5 (751f9) - Support multiple themes for
renderToHtmlDualThemes
- by @antfu (cedad) - Support no default color for dual themes, #6 - by @antfu in #6 (69b99)
- Add
codeToTokensWithThemes
, fix #7 - by @antfu and starknt in #7 (b3cb0) - Port back ansi support - by @antfu (80c74)
- Add rehype and markdown-it plugins - by @antfu in #12 (f096f)
- Wip
shikiji-compact
package - by @antfu (ea2d6) - Support passing raw theme object on generation - by @antfu (03db7)
- Improve compatibility - by @antfu (8e11f)
- Improve compat - by @antfu (3b41d)
- Support font-style for multiples themes - by @antfu (b6a42)
- Support lang on the meta - by @ovflowd in #26 (f0e6b)
- Treat
plain
as plain text, close #24 - by @antfu in #24 (6ae61) - Support multiple transformers - by @antfu (50466)
- Introduce transformers package - by @antfu in #32 (370a4)
- Add
preprocess
andpostprocess
hooks to transformer - by @antfu (c1aba) - Support lang alias - by @antfu (fe120)
- Introduce twoslash transformer - by @antfu in #39 (06742)
- Expose more utils - by @antfu (53343)
- Additional
codeToHast
util in transformer context - by @antfu (fc857) - Adjust css - by @antfu (724ad)
- New
shikiji-core
package, improve bundling - by @antfu in #42 (60184) - Introduce
shikiji-monaco
package - by @antfu (61794) - Provide more info for languages and themes - by @antfu (d187e)
- Support grammar injection - by @antfu in #48 (c176b)
- Change source from shiki to
tm-grammars
andtm-themes
- by @antfu (be0c9) - Introduce web bundle - by @antfu in #56 (9cc01)
- Introduce lazy embedded, more efficient bundle - by @antfu in #59 (90fa1)
- Call
preprocess
hook incodeToHast
- by @antfu (ed447) - Introduce
shikiji-cli
- by @antfu (68cd3) - Support arbitrary colors value in theme, support
colorReplacements
field - by @antfu in #68 (a5ee1) - Support
mergeWhitespaces: never
for themes are not handling perfectly - by @antfu (74459) - Update deps, a few new themes - by @antfu (6f92c)
- Improve wasm support - by @antfu (bee23)
- Also support wasm import module - by @antfu (637d2)
- Support also passing promises to
loadWasm
- by @antfu (b8694) - Support angular - by @antfu (a383d)
- Introduce
vitepress-plugin-twoslash
- by @antfu (cc128) - Support
unwasm
condition for core - by @antfu in #97 (71249) - Support configure
cache
option for twoslash transformer - by @antfu (d5773) - Upgrade to twoslash v0.1.0 - by @antfu (b6cbf)
- Add a special
none
theme - by @antfu in #115 (32f8a) - Support ansi background color, fix #432 - by @antfu in #432 (19455)
- Add fortran support - by @antfu (55706)
- Export
tokensToHast
- by @antfu (e959e) - Support passing
includeExplanation
, close #568 - by @antfu in #568 (cebf1) - Add
codeToTokens
API, renamecodeToThemedTokens
tocodeToTokensBase
- by @antfu in #572 (d123b) - Add
addClassToHast
to transformer context - by @antfu in #573 (6dfcd) - Introduce Decorations API - by @antfu in #574 (e0fcf)
- Apply full line decoration when possible - by @antfu (52f6a)
- compat:
- core:
- html:
- markdown-it:
- rehype:
- rehype-shikiji:
- transformers:
- Nations support range - by @antfu (543c2)
render-whitepsace
supportposition
option - by @antfu (ba679)- Introduce
transformerMetaHighlight
transformer - by @antfu (aa81a) - Two new transformers for word highlighting - by @fuma-nama and @antfu in #92 (ecf60)
- Support word highlighting across multiple tokens - by @fuma-nama and @antfu in #561 (70fdc)
- transforms:
- Add line node element to
token
transformer - by @innocenzi in #14 (116ec)
- Add line node element to
- twoslash:
- Support custom renderer - by @antfu (3fbd0)
- Support passing explicit trigger in markdown-it and rehype integration - by @antfu (66661)
- Expose core module, independent from twoslash - by @antfu in #52 (1c0d4)
- Expose
twoslasher
option to be override - by @antfu (ed1a1) - Add
classExtra
to rich renderer - by @antfu (383fc) - Allow provide custom trigger - by @antfu (6b177)
- Allow lossy custom twoslash implementation - by @antfu (38a9f)
- Support
errorRendering
to render error in hover style - by @antfu (28e32) - Support extend
popupError
- by @antfu (df62d) - Wrap tokens in a single span for errors - by @antfu (efea5)
- twoslash/rich:
- vitepress:
- vitepress-twoslash:
🐞 Bug Fixes
- Oniguruma options - by @antfu (45dd7)
- Make cf working - by @antfu (b01a6)
- Rename APIs - by @antfu (de1b6)
- Add type export - by @antfu (2a185)
.d.mts
for all - by @antfu (3c63c)- Allow loading multiple langs at once - by @antfu (a5c8e)
- Subpackages dts in node10 - by @userquin in #2 (11e6a)
- Support language alias - by @antfu (31816)
- Types - by @antfu (cd13e)
- Langs subpackage dts in node10 - by @userquin in #4 (18e26)
- Do not include any default themes/languages - by @antfu (56ce8)
- Improve type exchangeability - by @antfu (3944a)
- Allow to init the highlighter without themes and langs - by @antfu (705cd)
- Typo in ThemeRegistration - by @brc-dd in #11 (4dfc6)
- Typo - by @antfu (c6f53)
- Remove empty style - by @bluwy in #21 (7fd20)
- Add lang to HtmlRendererOptions - by @devjvao in #29 (a34ad)
- Revert #26, fix #30 - by @antfu in #26 and #30 (6f029)
- Improve transformers - by @antfu (182dc)
- Improve types - by @antfu (96fd6)
- Improve types in
ThemeRegistration
- by @GoodbyeNJN in #34 (21559) - Load all embedded langs with markdown - by @antfu in #36 (741b8)
- Improve
ThemeRegistration
type, close #63 - by @antfu in #63 (03d13) - Avoid merge style when visible styles are applied, close #65 - by @antfu in #65 (2c33a)
- Improve css variable handling for background - by @antfu (2964d)
- MergeWhitespaceTokens offset calculation - by @antfu (3cf46)
- Improve error handling - by @antfu (d9fcd)
- Update grammar registry, fix html in markdown highlighting - by @antfu (502ed)
- Stricter types - by @antfu (1b3dc)
- SplitLines extra new lines, fix #576 - by @antfu in #576 (0bb28)
- compact:
- compat:
- core:
- dual-theme:
- markdown-it:
- monaco:
- rehype-shikiji:
- transformers:
- twoslash:
- Fix popover offset calculation - by @antfu (5c8fc)
- Avoid deps on typescript runtime - by @antfu (5d411)
- Should not throw when
throws: true
- by @antfu (dd6c7) - Split tokens to match the twoslash nodes - by @antfu (9016d)
- Support targeting multiple tokens a node, more accurate result - by @antfu (23ece)
- Avoid genreate duplicate hovers - by @antfu (04352)
- Respect twoslash output lang - by @antfu (a5a8a)
- Completion on string quotes and literals - by @jxom and @antfu in #99 (c1e9c)
- Completion on multifile - by @jxom and @antfu in #100 (ac629)
- Adjust styles - by @antfu (2602b)
- Split tokens on completion - by @antfu (3f349)
- Improve css variables definition - by @antfu (68429)
- Improve types - by @antfu (5a177)
- twoslash/rich:
- types:
- vitepress:
- vitepress-plugin-twoslash:
- vitepress-twoslash:
🏎 Performance
- Optimize internal logic - by @antfu (852dd)
- Cleanup unused attribute in themes and langs - by @antfu (38c88)
- Skip
setTheme
if theme hasn't changed - by @banga in #66 (c6f82) - cli: Use Promise.all - by @Plumbiu in #104 (ddb94)
- vitepress: Add v-pre to docs - by @antfu (72440)