tinymist/syntaxes/textmate
Myriad-Dreamin f2a10fec2f
Some checks failed
tinymist::auto_tag / auto-tag (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / announce (push) Has been cancelled
tinymist::ci / build (push) Has been cancelled
build: bump version to 0.14.0-rc1 (#2189)
+tag v0.14.0-rc1
2025-10-29 12:22:35 +08:00
..
scripts build: make use of async io of js to speed up vscode builds (#2069) 2025-08-31 18:34:20 +08:00
tests fix: stop atom expressions before backslash (#1835) 2025-06-23 11:32:55 +08:00
.gitignore fix: exclude content block syntax when parsing math arguments (#1124) 2025-01-07 14:18:11 +08:00
feature.ts build: make use of async io of js to speed up vscode builds (#2069) 2025-08-31 18:34:20 +08:00
fenced.meta.ts build: make use of async io of js to speed up vscode builds (#2069) 2025-08-31 18:34:20 +08:00
fenced.ts build: make use of async io of js to speed up vscode builds (#2069) 2025-08-31 18:34:20 +08:00
main.ts build: make use of async io of js to speed up vscode builds (#2069) 2025-08-31 18:34:20 +08:00
package.json build: bump version to 0.14.0-rc1 (#2189) 2025-10-29 12:22:35 +08:00
README.md docs: documenting textmate grammar (#1131) 2025-01-08 12:40:19 +08:00
textmate.ts build: make use of async io of js to speed up vscode builds (#2069) 2025-08-31 18:34:20 +08:00
tsconfig.json build: make use of async io of js to speed up vscode builds (#2069) 2025-08-31 18:34:20 +08:00

Syntax Highlighting for Typst

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.

Building

The following script running the TypeScript program will generate the TextMate grammar file:

yarn compile

Testing

// Run unit tests
yarn test
// Test on typst/typst
yarn test:official
// Test on typst/packages
yarn test:packages

Register languages for raw highlighting

Goto fenced.meta.mts and add a line like this:

{ "candidates": ["erlang"] }

Three possible kinds:

  • { candidates: ["someLanguage", ...rests] } - using textmate parser registered as source.someLanguage.
    • The rests of the candidates can also be used as language tag of fenced code blocks.
  • { as: "text.xxx", candidates } - using textmate parser registered as text.xxx.
  • { as: ["text.xxx", ...restScopes], candidates } - using textmate parser text.xxx first, and restScopes parsers in order.

GitHub Integration

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-grammar

You can setup your owned environment according to github-linguist's CONTRIBUTING.md to develop the variant locally.

Contributing

See CONTRIBUTING.md.