This folder contains the syntax highlighting in the TextMate format for Typst.
To tackle challenge of making the complex grammar for typst markup, the grammar is described by neither JSON nor YAML, but a TypeScript generator program, the ./main.ts. TypeScript ensures correct grammar by static and strong types from ./textmate.ts.
The following script running the TypeScript program will generate the TextMate grammar file:
yarn compile// Run unit tests
yarn test
// Test on typst/typst
yarn test:official
// Test on typst/packages
yarn test:packagesGoto fenced.meta.mts and add a line like this:
{ "candidates": ["erlang"] }Three possible kinds:
{ candidates: ["someLanguage", ...rests] }- using textmate parser registered assource.someLanguage.- The
restsof the candidates can also be used as language tag of fenced code blocks.
- The
{ as: "text.xxx", candidates }- using textmate parser registered astext.xxx.{ as: ["text.xxx", ...restScopes], candidates }- using textmate parsertext.xxxfirst, andrestScopesparsers in order.
A variant satisfying GitHub's requirement is managed on Typst Grammar Repo. You can check which version the repository is using by checking the build-ref.md or build-ref.json.
The grammar is built by the build branch's CI.
The grammar is tested continuously by the main branch's CI. Specifically, it is tested by the command in the CI script:
script/grammar-compiler add vendor/grammars/typst-grammarYou can setup your owned environment according to github-linguist's CONTRIBUTING.md to develop the variant locally.
See CONTRIBUTING.md.