├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ ├── feature_request.yml │ └── typo.yml ├── pull_request_template.md └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .npmrc ├── .vscode ├── extensions.json └── settings.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bench ├── bundle-test │ ├── bundle.bench.ts │ ├── index-lite.ts │ ├── index-wasm.ts │ ├── package.json │ └── rollup.config.mjs └── engines │ └── engines.bench.ts ├── bump.config.ts ├── docs ├── .vitepress │ ├── components │ │ ├── Badges.vue │ │ ├── HomeDemo.vue │ │ ├── LanguagesList.vue │ │ ├── ShikiMiniPlayground.vue │ │ ├── ShikiPlayground.vue │ │ └── ThemesList.vue │ ├── config.ts │ ├── store │ │ └── playground.ts │ ├── theme │ │ ├── index.ts │ │ ├── style.css │ │ └── transformers.css │ ├── uno.config.ts │ └── vite.config.ts ├── api.md ├── blog │ ├── v2.md │ └── v3.md ├── components.d.ts ├── guide │ ├── best-performance.md │ ├── bundles.md │ ├── compat.md │ ├── decorations.md │ ├── dual-themes.md │ ├── grammar-state.md │ ├── index.md │ ├── install.md │ ├── load-lang.md │ ├── load-theme.md │ ├── migrate.md │ ├── regex-engines.md │ ├── shorthands.md │ ├── sync-usage.md │ ├── theme-colors.md │ └── transformers.md ├── index.md ├── languages.md ├── package.json ├── packages │ ├── astro.md │ ├── cli.md │ ├── codegen.md │ ├── colorized-brackets.md │ ├── markdown-it.md │ ├── monaco.md │ ├── next.md │ ├── nuxt.md │ ├── rehype.md │ ├── transformers.md │ ├── twoslash.md │ └── vitepress.md ├── play.md ├── public │ ├── logo.svg │ └── og.png ├── references │ └── engine-js-compat.md ├── themes.md └── tsconfig.json ├── eslint.config.js ├── netlify.toml ├── package.json ├── packages ├── cli │ ├── README.md │ ├── bin.mjs │ ├── build.config.ts │ ├── package.json │ └── src │ │ ├── cli.ts │ │ ├── code-to-ansi.ts │ │ ├── colors.ts │ │ └── index.ts ├── codegen │ ├── README.md │ ├── bin.mjs │ ├── build.config.ts │ ├── package.json │ ├── src │ │ ├── cli.ts │ │ └── index.ts │ └── test │ │ ├── __snapshots__ │ │ ├── basic-oniguruma-js.js │ │ ├── basic-oniguruma.ts │ │ └── basic-precompiled.ts │ │ └── codegen.test.ts ├── colorized-brackets │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── scripts │ │ └── prepare.ts │ ├── src │ │ ├── colorizeBracketTokens.ts │ │ ├── index.ts │ │ ├── splitBracketTokens.ts │ │ ├── types.ts │ │ └── utils.ts │ └── test │ │ ├── bracket-customization.test.ts │ │ ├── dual-themes.test.ts │ │ ├── explicit-trigger.test.ts │ │ ├── fixtures.test.ts │ │ ├── fixtures │ │ ├── csharp │ │ │ └── generic.cs │ │ ├── css │ │ │ └── basic.css │ │ ├── html │ │ │ ├── basic.html │ │ │ └── embedded.html │ │ ├── java │ │ │ └── generic.java │ │ ├── jinja │ │ │ └── basic.jinja │ │ ├── liquid │ │ │ └── basic.liquid │ │ ├── python │ │ │ └── basic.py │ │ ├── rust │ │ │ ├── generic.rs │ │ │ └── turbofish.rs │ │ ├── svelte │ │ │ └── embedded.svelte │ │ ├── ts │ │ │ ├── angle-brackets.ts │ │ │ ├── comments.ts │ │ │ ├── generic.ts │ │ │ ├── jsdoc.ts │ │ │ ├── strings.ts │ │ │ ├── template.ts │ │ │ └── unexpected.txt │ │ └── tsx │ │ │ └── basic.tsx │ │ └── utils.ts ├── core │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── src │ │ ├── constructors │ │ │ ├── bundle-factory.ts │ │ │ ├── highlighter.ts │ │ │ ├── internal-sync.ts │ │ │ └── internal.ts │ │ ├── highlight │ │ │ ├── _get-transformers.ts │ │ │ ├── code-to-hast.ts │ │ │ ├── code-to-html.ts │ │ │ ├── code-to-tokens-ansi.ts │ │ │ ├── code-to-tokens-base.ts │ │ │ ├── code-to-tokens-themes.ts │ │ │ └── code-to-tokens.ts │ │ ├── index.ts │ │ ├── textmate.ts │ │ ├── textmate │ │ │ ├── getters-resolve.ts │ │ │ ├── grammar-state.ts │ │ │ ├── normalize-theme.ts │ │ │ ├── registry.ts │ │ │ └── resolver.ts │ │ ├── theme-css-variables.ts │ │ ├── transformer-decorations.ts │ │ ├── types.ts │ │ ├── utils │ │ │ ├── colors.ts │ │ │ ├── general.ts │ │ │ ├── hast.ts │ │ │ ├── index.ts │ │ │ ├── strings.ts │ │ │ └── tokens.ts │ │ └── warn.ts │ └── test │ │ ├── __snapshots__ │ │ └── tokens.test.ts.snap │ │ ├── core-sync.test.ts │ │ ├── core.test.ts │ │ ├── css-variables.test.ts │ │ ├── decorations.test.ts │ │ ├── hast.test.ts │ │ ├── injections.test.ts │ │ ├── out │ │ ├── decorations │ │ │ └── basic.html │ │ ├── injections-side-effects-angular-after.html │ │ ├── injections-side-effects-angular-before.html │ │ ├── injections-side-effects-angular-ts-after.html │ │ ├── injections-side-effects-angular-ts-before.html │ │ ├── injections-side-effects-vue-after.html │ │ ├── injections-side-effects-vue-before.html │ │ └── vue-injections.html │ │ ├── tokens.test.ts │ │ ├── transformers.test.ts │ │ └── utils.test.ts ├── engine-javascript │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── src │ │ ├── engine-compile.ts │ │ ├── engine-raw.ts │ │ ├── index.ts │ │ └── scanner.ts │ └── test │ │ ├── __records__ │ │ ├── beancount.js.json │ │ ├── beancount.wasm.json │ │ ├── html-basic.js.json │ │ ├── html-basic.wasm.json │ │ ├── json-basic.js.json │ │ ├── json-basic.wasm.json │ │ ├── jsonc.js.json │ │ ├── jsonc.wasm.json │ │ ├── markdown.js.json │ │ ├── markdown.wasm.json │ │ ├── sql.js.json │ │ ├── sql.wasm.json │ │ ├── toml.js.json │ │ ├── toml.wasm.json │ │ ├── ts-basic.js.json │ │ ├── ts-basic.wasm.json │ │ ├── vue.js.json │ │ └── vue.wasm.json │ │ ├── compare.test.ts │ │ ├── general.test.ts │ │ ├── out │ │ └── monokai-underline.html │ │ ├── raw.test.ts │ │ ├── types.ts │ │ └── verify.test.ts ├── engine-oniguruma │ ├── README.md │ ├── package.json │ ├── rollup.config.mjs │ ├── src │ │ ├── index.ts │ │ ├── oniguruma │ │ │ ├── LICENSE │ │ │ ├── index.ts │ │ │ └── onig.ts │ │ └── wasm-inlined.ts │ └── test │ │ ├── wasm1.test.ts │ │ ├── wasm2.test.ts │ │ ├── wasm3.test.ts │ │ ├── wasm4.test.ts │ │ ├── wasm5.test.ts │ │ └── wasm6.test.ts ├── langs-precompiled │ ├── README.md │ ├── package.json │ ├── scripts │ │ ├── langs.ts │ │ ├── precompile.ts │ │ └── prepare.ts │ └── tests │ │ ├── __snapshots__ │ │ ├── precompile-run.test.ts.snap │ │ └── precompile-serialize.test.ts.snap │ │ ├── precompile-run.test.ts │ │ └── precompile-serialize.test.ts ├── langs │ ├── README.md │ ├── package.json │ └── scripts │ │ ├── langs.ts │ │ └── prepare.ts ├── markdown-it │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── src │ │ ├── async.ts │ │ ├── common.ts │ │ ├── core.ts │ │ └── index.ts │ └── test │ │ ├── async.test.ts │ │ ├── fixtures │ │ ├── a.async.out.html │ │ ├── a.md │ │ ├── a.out.html │ │ ├── b.md │ │ ├── b.out.html │ │ ├── c.md │ │ ├── c.out.html │ │ ├── lang-alias.md │ │ └── lang-alias.out.html │ │ └── index.test.ts ├── monaco │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── playground │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ └── main.ts │ │ └── vite.config.ts │ └── src │ │ ├── index.ts │ │ ├── tokenizer.ts │ │ ├── types.ts │ │ └── utils.ts ├── rehype │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── src │ │ ├── core.ts │ │ ├── handlers.ts │ │ ├── index.ts │ │ └── types.ts │ └── test │ │ ├── core.test.ts │ │ ├── fixtures │ │ ├── a.core.out.html │ │ ├── a.md │ │ ├── a.out.html │ │ ├── b.md │ │ ├── b.out.html │ │ ├── c.md │ │ ├── c.out.html │ │ ├── d.md │ │ ├── d.out.html │ │ ├── inline.md │ │ ├── inline.out.html │ │ ├── lang-alias.md │ │ └── lang-alias.out.html │ │ └── index.test.ts ├── shiki │ ├── NOTICE │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── scripts │ │ └── prepare.ts │ ├── src │ │ ├── bundle-full.ts │ │ ├── bundle-web.ts │ │ ├── core-unwasm.ts │ │ ├── core.ts │ │ ├── engine-javascript.ts │ │ ├── engine-oniguruma.ts │ │ ├── index.ts │ │ ├── langs-bundle-full.ts │ │ ├── langs-bundle-web.ts │ │ ├── langs.ts │ │ ├── textmate.ts │ │ ├── themes.ts │ │ ├── types.ts │ │ └── wasm.ts │ └── test │ │ ├── ansi.test.ts │ │ ├── bundle.test.ts │ │ ├── cf.ts │ │ ├── color-replacement.test.ts │ │ ├── dist.test.ts │ │ ├── general.test.ts │ │ ├── get-highlighter.test.ts │ │ ├── grammar-state.test.ts │ │ ├── out │ │ ├── ansi-background.html │ │ ├── ansi-dark-plus.html │ │ ├── ansi.html │ │ ├── dual-themes.html │ │ ├── monokai-underline.html │ │ ├── multiple-themes-no-default.html │ │ ├── multiple-themes.html │ │ ├── shorthand-markdown1.html │ │ └── shorthand-markdown2.html │ │ ├── shorthands-markdown.test.ts │ │ ├── shorthands.test.ts │ │ ├── theme-none.test.ts │ │ └── themes.test.ts ├── themes │ ├── README.md │ ├── package.json │ └── scripts │ │ ├── prepare.ts │ │ └── themes.ts ├── transformers │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── shared │ │ │ ├── highlight-word.ts │ │ │ ├── notation-transformer.ts │ │ │ ├── parse-comments.ts │ │ │ └── utils.ts │ │ └── transformers │ │ │ ├── compact-line-options.ts │ │ │ ├── meta-highlight-word.ts │ │ │ ├── meta-highlight.ts │ │ │ ├── notation-diff.ts │ │ │ ├── notation-error-level.ts │ │ │ ├── notation-focus.ts │ │ │ ├── notation-highlight-word.ts │ │ │ ├── notation-highlight.ts │ │ │ ├── notation-map.ts │ │ │ ├── remove-line-breaks.ts │ │ │ ├── remove-notation-escape.ts │ │ │ ├── render-whitespace.ts │ │ │ └── style-to-class.ts │ └── test │ │ ├── fixtures.test.ts │ │ ├── fixtures │ │ ├── all │ │ │ ├── a.js │ │ │ └── a.js.output.html │ │ ├── diff │ │ │ ├── a.js │ │ │ └── a.js.output.html │ │ ├── error-level │ │ │ ├── a.js │ │ │ └── a.js.output.html │ │ ├── focus │ │ │ ├── a.js │ │ │ ├── a.js.output.html │ │ │ ├── empty-line-comment.js │ │ │ ├── empty-line-comment.js.output.html │ │ │ ├── mutliple-lines.js │ │ │ └── mutliple-lines.js.output.html │ │ ├── highlight-word │ │ │ ├── basic.js │ │ │ ├── basic.js.output.html │ │ │ ├── complex.js │ │ │ ├── complex.js.output.html │ │ │ ├── mutliple-words.js │ │ │ ├── mutliple-words.js.output.html │ │ │ ├── occurrence.js │ │ │ └── occurrence.js.output.html │ │ ├── highlight │ │ │ ├── a.js │ │ │ ├── a.js.output.html │ │ │ ├── comment-highlight.js │ │ │ ├── comment-highlight.js.output.html │ │ │ ├── empty-line-comment-leading.js │ │ │ ├── empty-line-comment-leading.js.output.html │ │ │ ├── empty-line-comment.js │ │ │ ├── empty-line-comment.js.output.html │ │ │ ├── mutliple-lines.js │ │ │ ├── mutliple-lines.js.output.html │ │ │ ├── query.sql │ │ │ └── query.sql.output.html │ │ ├── match-algorithm │ │ │ ├── v1.js │ │ │ ├── v1.js.output.html │ │ │ ├── v3.js │ │ │ └── v3.js.output.html │ │ └── whitespace │ │ │ ├── a.js │ │ │ ├── a.js.all.output.html │ │ │ ├── a.js.boundary.output.html │ │ │ ├── a.js.trailing.output.html │ │ │ ├── b.js │ │ │ ├── b.js.all.output.html │ │ │ ├── b.js.boundary.output.html │ │ │ ├── b.js.trailing.output.html │ │ │ ├── c.js │ │ │ ├── c.js.all.output.html │ │ │ ├── c.js.boundary.output.html │ │ │ └── c.js.trailing.output.html │ │ ├── meta-line-highlight.test.ts │ │ ├── meta-word-highlight.test.ts │ │ ├── style-to-class.test.ts │ │ ├── utils.test.ts │ │ └── whitespace-inline.test.ts ├── twoslash │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── scripts │ │ └── icons.ts │ ├── src │ │ ├── core.ts │ │ ├── error.ts │ │ ├── icons-completions.json │ │ ├── icons-tags.json │ │ ├── icons.ts │ │ ├── includes.ts │ │ ├── index.ts │ │ ├── renderer-classic.ts │ │ ├── renderer-rich.ts │ │ └── types.ts │ ├── style-classic.css │ ├── style-rich.css │ └── test │ │ ├── classic.test.ts │ │ ├── fixtures.test.ts │ │ ├── fixtures │ │ ├── completion-end-multifile-2.ts │ │ ├── completion-end-multifile.ts │ │ ├── completion-end.ts │ │ ├── completion-string.ts │ │ ├── highlights.ts │ │ ├── import-vue.ts │ │ └── query-offset.ts │ │ ├── includes.test.ts │ │ ├── markdown-it.test.ts │ │ ├── out │ │ ├── classic │ │ │ ├── compiler_errors.html │ │ │ ├── completions.html │ │ │ ├── console_log.html │ │ │ ├── cuts_out_unnecessary_code.html │ │ │ └── simple.html │ │ ├── completion-end-multifile-2.ts.html │ │ ├── completion-end-multifile-2.ts.json │ │ ├── completion-end-multifile.ts.html │ │ ├── completion-end-multifile.ts.json │ │ ├── completion-end.ts.html │ │ ├── completion-end.ts.json │ │ ├── completion-string.ts.html │ │ ├── completion-string.ts.json │ │ ├── error-multi-tokens.html │ │ ├── fixtures │ │ │ ├── completion-end-multifile-2.ts.html │ │ │ ├── completion-end-multifile-2.ts.json │ │ │ ├── completion-end-multifile.ts.html │ │ │ ├── completion-end-multifile.ts.json │ │ │ ├── completion-end.ts.html │ │ │ ├── completion-end.ts.json │ │ │ ├── highlights.ts.html │ │ │ ├── highlights.ts.json │ │ │ ├── import-vue.ts.html │ │ │ ├── import-vue.ts.json │ │ │ ├── query-offset.ts.html │ │ │ └── query-offset.ts.json │ │ ├── highlights.ts.html │ │ ├── highlights.ts.json │ │ ├── import-vue.ts.html │ │ ├── import-vue.ts.json │ │ ├── includes │ │ │ ├── main.html │ │ │ ├── nested_includes-a.html │ │ │ ├── nested_includes-b.html │ │ │ ├── nested_includes-c.html │ │ │ └── replaced_directives.html │ │ ├── markdown-it │ │ │ ├── highlight-disable-triggers.html │ │ │ ├── highlight-lines.html │ │ │ └── works.html │ │ ├── query-offset.ts.html │ │ ├── query-offset.ts.json │ │ └── rich │ │ │ ├── custom-tags.html │ │ │ ├── line-query.html │ │ │ ├── no-icons.html │ │ │ ├── rich-error-hover.html │ │ │ ├── rich-none-theme.html │ │ │ └── rich.html │ │ ├── rich.test.ts │ │ ├── target-multi-tokens.test.ts │ │ └── token-split.test.ts ├── types │ ├── README.md │ ├── build.config.ts │ ├── package.json │ └── src │ │ ├── bundle-factory.ts │ │ ├── decorations.ts │ │ ├── engines.ts │ │ ├── error.ts │ │ ├── highlighter.ts │ │ ├── index.ts │ │ ├── langs.ts │ │ ├── options.ts │ │ ├── textmate.ts │ │ ├── themes.ts │ │ ├── tokens.ts │ │ ├── transformers.ts │ │ └── utils.ts └── vitepress-twoslash │ ├── .gitignore │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── src │ ├── cache-fs.ts │ ├── client.ts │ ├── index.ts │ ├── renderer-floating-vue.ts │ ├── style.css │ └── types.ts │ └── test │ ├── fixtures.test.ts │ └── out │ ├── completion-end-multifile-2.ts.html │ ├── completion-end-multifile-2.ts.json │ ├── completion-end-multifile.ts.html │ ├── completion-end-multifile.ts.json │ ├── completion-end.ts.html │ ├── completion-end.ts.json │ ├── completion-string.ts.json │ ├── highlights.ts.html │ ├── highlights.ts.json │ ├── import-vue.ts.html │ ├── import-vue.ts.json │ ├── query-offset.ts.html │ └── query-offset.ts.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── scripts ├── report-engine-js-compat.ts └── utils.ts ├── taze.config.ts ├── test ├── exports.test.ts └── exports │ ├── @shikijs │ ├── cli.yaml │ ├── colorized-brackets.yaml │ ├── core.yaml │ ├── engine-javascript.yaml │ ├── engine-oniguruma.yaml │ ├── markdown-it.yaml │ ├── monaco.yaml │ ├── rehype.yaml │ ├── transformers.yaml │ ├── twoslash.yaml │ ├── types.yaml │ └── vitepress-twoslash.yaml │ ├── shiki-codegen.yaml │ └── shiki.yaml ├── tsconfig.json └── vitest.config.ts /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | docs/* linguist-documentation 3 | **/test/out/** linguist-generated 4 | **/test/fixtures/** linguist-generated 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [antfu, octref] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: 🙌 Contribution Guide 3 | url: https://github.com/shikijs/shiki/blob/main/CONTRIBUTING.md 4 | about: Please read through before making contributions. 5 | - name: 🧑‍💻 Contribute to New Grammar 6 | url: https://github.com/shikijs/textmate-grammars-themes/#add-a-new-grammar 7 | about: Shiki uses grammars collected by `tm-grammars`. Contribute there will inherit to Shiki. 8 | - name: 🌈 Contribute to New Theme 9 | url: https://github.com/shikijs/textmate-grammars-themes/#add-a-new-grammar 10 | about: Shiki uses themes collected by `tm-themes`. Contribute there will inherit to Shiki. 11 | - name: ⁉️ Why and How to make a reproduction? 12 | url: https://antfu.me/posts/why-reproductions-are-required 13 | about: Reproduction is very important for maintainer to help on your issues! 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/typo.yml: -------------------------------------------------------------------------------- 1 | name: 👀 Typo / Grammar fix 2 | description: You can just go ahead and send a PR! Thank you! 3 | labels: [] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | ## PR Welcome! 9 | 10 | If the typo / grammar issue is trivial and straightforward, you can help by **directly sending a quick pull request**! 11 | If you spot multiple of them, we suggest combining them into a single PR. Thanks! 12 | - type: textarea 13 | id: context 14 | attributes: 15 | label: Additional context 16 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 13 | 14 | ### Description 15 | 16 | 17 | 18 | ### Linked Issues 19 | 20 | ### Additional context 21 | 22 | 23 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | permissions: 4 | contents: write 5 | id-token: write 6 | 7 | on: 8 | push: 9 | tags: 10 | - 'v*' 11 | 12 | jobs: 13 | release: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | - uses: actions/setup-node@v4 20 | with: 21 | node-version: lts/* 22 | registry-url: https://registry.npmjs.org/ 23 | - uses: pnpm/action-setup@v4 24 | - run: pnpm install 25 | - run: npx changelogithub 26 | continue-on-error: true 27 | env: 28 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 29 | - run: pnpm run publish:ci 30 | env: 31 | NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} 32 | NPM_CONFIG_PROVENANCE: true 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | .DS_Store 3 | .idea 4 | *.log 5 | *.tgz 6 | .temp 7 | coverage 8 | dist 9 | lib-cov 10 | logs 11 | node_modules 12 | temp 13 | tmp 14 | packages/colorized-brackets/src/themes.ts 15 | packages/shiki/src/langs 16 | packages/shiki/src/themes 17 | packages/shiki/src/*.json 18 | packages/shiki/src/langs 19 | packages/shiki/src/themes 20 | cache 21 | .eslintcache 22 | report-engine-js-compat.json 23 | scripts/compares 24 | tm-grammars-themes 25 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | ignore-workspace-root-check=true 2 | shamefully-hoist=true 3 | shell-emulator=true 4 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "antfu.pnpm-catalog-lens" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // Disable the default formatter 3 | "prettier.enable": false, 4 | "editor.formatOnSave": false, 5 | 6 | // Auto fix 7 | "editor.codeActionsOnSave": { 8 | "source.fixAll.eslint": "explicit", 9 | "source.organizeImports": "never" 10 | }, 11 | 12 | // Silent the stylistic rules in you IDE, but still auto fix them 13 | "eslint.rules.customizations": [ 14 | { "rule": "@stylistic/*", "severity": "off" }, 15 | { "rule": "*-indent", "severity": "off" }, 16 | { "rule": "*-spacing", "severity": "off" }, 17 | { "rule": "*-spaces", "severity": "off" }, 18 | { "rule": "*-order", "severity": "off" }, 19 | { "rule": "*-dangle", "severity": "off" }, 20 | { "rule": "*-newline", "severity": "off" }, 21 | { "rule": "*quotes", "severity": "off" }, 22 | { "rule": "*semi", "severity": "off" } 23 | ], 24 | 25 | "eslint.validate": [ 26 | "javascript", 27 | "javascriptreact", 28 | "typescript", 29 | "typescriptreact", 30 | "vue", 31 | "html", 32 | "markdown", 33 | "json", 34 | "jsonc", 35 | "yaml" 36 | ], 37 | "references.preferredLocation": "peek", 38 | "cSpell.words": [ 39 | "Extenerlaize", 40 | "shikijs" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Pine Wu 4 | Copyright (c) 2023 Anthony Fu 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Shiki Logo 2 | 3 | # Shiki 式 4 | 5 | [![NPM version](https://img.shields.io/npm/v/shiki?color=32A9C3&labelColor=1B3C4A&label=npm)](https://www.npmjs.com/package/shiki) 6 | [![NPM downloads](https://img.shields.io/npm/dm/shiki?color=32A9C3&labelColor=1B3C4A&label=downloads)](https://www.npmjs.com/package/shiki) 7 | [![Codecov](https://img.shields.io/codecov/c/github/shikijs/shiki?token=1uJYfXgZG3&style=flat&labelColor=1B3C4A&color=32A9C3&precision=1)](https://app.codecov.io/gh/shikijs/shiki/tree) 8 | 9 | A beautiful syntax highlighter based on TextMate grammar, accurate and powerful. 10 | 11 | [📚 **Documentation**](https://shiki.style) 12 | 13 | ## Branch 14 | 15 | The main branch is currently at _v3.x_. 16 | 17 | | Branch | Description | 18 | | ---------------------------------------------- | ---------------------------------- | 19 | | [v2](https://github.com/shikijs/shiki/tree/v2) | v2.5 of Shiki | 20 | | [v1](https://github.com/shikijs/shiki/tree/v1) | v1.29 of Shiki | 21 | | [v0](https://github.com/shikijs/shiki/tree/v0) | v0.14 of Shiki, the legacy version | 22 | 23 | ## License 24 | 25 | [MIT](./LICENSE) 26 | -------------------------------------------------------------------------------- /bench/bundle-test/bundle.bench.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable ts/ban-ts-comment */ 2 | /* eslint-disable antfu/no-import-dist */ 3 | 4 | import { bench, describe } from 'vitest' 5 | // @ts-ignore - ignore type error 6 | import { highlight as highlightA } from './dist/index-lite.min.mjs' 7 | // @ts-ignore - ignore type error 8 | import { highlight as highlightB } from './dist/index-wasm.min.mjs' 9 | 10 | const code = ` 11 | import { ref } from 'vue' 12 | 13 | const message = ref('Hello World!') 14 | 15 | function reverseMessage() { 16 | // Access/mutate the value of a ref via 17 | // its .value property. 18 | message.value = message.value.split('').reverse().join('') 19 | } 20 | 21 | function notify() { 22 | alert('navigation was prevented.') 23 | } 24 | ` 25 | 26 | describe('bundle', () => { 27 | bench('js-precompiled', async () => { 28 | await highlightA(code) 29 | }) 30 | 31 | bench('wasm', async () => { 32 | await highlightB(code) 33 | }) 34 | }) 35 | -------------------------------------------------------------------------------- /bench/bundle-test/index-lite.ts: -------------------------------------------------------------------------------- 1 | import { codeToHtml, createShikiInternal } from '@shikijs/core' 2 | import { createJavaScriptRawEngine } from '@shikijs/engine-javascript/raw' 3 | 4 | const shiki = createShikiInternal( 5 | { 6 | langs: [ 7 | import('@shikijs/langs-precompiled/ts'), 8 | ], 9 | themes: [ 10 | import('@shikijs/themes/vitesse-dark'), 11 | ], 12 | engine: createJavaScriptRawEngine(), 13 | }, 14 | ) 15 | 16 | export async function highlight(code: string): Promise { 17 | return codeToHtml(await shiki, code, { lang: 'ts', theme: 'vitesse-dark' }) 18 | } 19 | -------------------------------------------------------------------------------- /bench/bundle-test/index-wasm.ts: -------------------------------------------------------------------------------- 1 | import { codeToHtml, createShikiInternal } from '@shikijs/core' 2 | import { createOnigurumaEngine } from '@shikijs/engine-oniguruma' 3 | 4 | const shiki = createShikiInternal( 5 | { 6 | langs: [ 7 | import('@shikijs/langs/ts'), 8 | ], 9 | themes: [ 10 | import('@shikijs/themes/vitesse-dark'), 11 | ], 12 | engine: createOnigurumaEngine(import('@shikijs/engine-oniguruma/wasm-inlined')), 13 | }, 14 | ) 15 | 16 | export async function highlight(code: string): Promise { 17 | return codeToHtml(await shiki, code, { lang: 'ts', theme: 'vitesse-dark' }) 18 | } 19 | -------------------------------------------------------------------------------- /bench/bundle-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "bench:prepare": "rollup -c && du -h dist/*" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /bench/bundle-test/rollup.config.mjs: -------------------------------------------------------------------------------- 1 | import resolve from '@rollup/plugin-node-resolve' 2 | import esbuild from 'rollup-plugin-esbuild' 3 | 4 | const plugins = [ 5 | resolve(), 6 | esbuild({ 7 | minify: true, 8 | target: 'esnext', 9 | }), 10 | ] 11 | 12 | export default [ 13 | { 14 | input: 'index-wasm.ts', 15 | output: { 16 | file: 'dist/index-wasm.min.mjs', 17 | format: 'es', 18 | inlineDynamicImports: true, 19 | }, 20 | plugins, 21 | }, 22 | { 23 | input: 'index-lite.ts', 24 | output: { 25 | file: 'dist/index-lite.min.mjs', 26 | format: 'es', 27 | inlineDynamicImports: true, 28 | }, 29 | plugins, 30 | }, 31 | ] 32 | -------------------------------------------------------------------------------- /bump.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'bumpp' 2 | 3 | export default defineConfig({ 4 | files: [ 5 | 'package.json', 6 | 'packages/*/package.json', 7 | ], 8 | }) 9 | -------------------------------------------------------------------------------- /docs/.vitepress/components/Badges.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 14 | -------------------------------------------------------------------------------- /docs/.vitepress/components/HomeDemo.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /docs/.vitepress/components/ShikiPlayground.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 |