Contributing Guide
Thanks for lending a hand 👋
Development
Clone
This repository contains a git submodule to vscode-textmate. By default git clone does not clone submodules. To clone this repository and its submodules, use:
git clone --recursive https://github.com/shikijs/shiki
Or if you have already cloned it, use:
git submodule update --init --recursive
Learn more at this StackOverflow thread.
Setup
- We use pnpm to manage dependencies. Install it with
npm i -g pnpm. - Install dependencies with
pnpm i. - Build all packages with
pnpm build.
Packages Structure
graph TD
tm-grammars([tm-grammars]) -.-> shiki
core --> shiki
tm-themes([tm-themes]) -.-> shiki
shiki{{shiki}} --> twoslash
shiki --> markdown-it
shiki --> compat[/compat\]
shiki --> rehype
shiki --> monaco
transformers
corecontains the core logic of Shiki, without any languages/themes prebundled. Published as@shikijs/core.shikiis the main package that bundles languages/themes fromtm-grammarsandtm-themesfor easier usage. Published asshiki.compatcontains the compatibility layer for Shiki v0.x. Published as@shikijs/compat.transformerscontains common transformers for Shiki. Published as@shikijs/transformer.- The rest of the packages are high-level integrations on top of
shiki.
Testing
- We use Vitest to test the codebase. Run
pnpm testto start the test runner. - We have quite some Snapshot Tests to ensure the output is consistent. If you are making changes to the output, run
pnpm test -uto update the snapshots.
Coding conventions
- We use ESLint to lint and format the codebase. Before you commit, all files will be formatted automatically.
- We use Conventional Commits. Please use a prefix. If your PR has multiple commits and some of them don't follow the Conventional Commits rule, we'll do a squash merge.
