mdbook-treesitter

Crates.iomdbook-treesitter
lib.rsmdbook-treesitter
version1.1.0
created_at2023-04-02 17:59:46.764942+00
updated_at2025-11-30 18:54:50.216172+00
descriptionmdbook-treesitter is an mdBook preprocessor for html adding tree-sitter highlighting support.
homepagehttps://github.com/Corpauration/mdbook-treesitter
repositoryhttps://github.com/Corpauration/mdbook-treesitter
max_upload_size
id828517
size35,288
(alyrow)

documentation

README

mdbook-treesitter

mdbook-treesitter is an mdBook preprocessor for html adding tree-sitter highlighting support.

It simply translates the tree-sitter highlighting into highlightjs one.

Installation

Install the preprocessor:

cargo install mdbook-treesitter

Configure mdBook

Add this in your book.toml:

[preprocessor.treesitter]
command = "mdbook-treesitter"
languages = ["javascript"]

Usage

Use usual codeblocks like that:

```javascript
console.log(this.a + b + "c" + 4);
```

Wait, you need to add related tree-sitter files:

  • Create a folder treesitter in the root of your mdBook project
  • Then, add your language_name.so in the created folder
    • Note: This also works on Windows systems, copy the tree-sitter parser.dll as language_name.so, even if it is not a *.so file.
  • Next, create a folder language_name in the tree-sitter folder
  • Finally, add in it your scm files

Example for javascript:

- My awesome mdBook/
    - book.toml
    - book/
    - src/
    - treesitter/
        - javascript.so
        - javascript/
            - highlights.scm
            - injections.scm
            - locals.scm

   

🧃

Commit count: 25

cargo fmt