Skip to main content

Crate mdbook_treesitter

Crate mdbook_treesitter 

Source
Expand description

mdbook-treesitter — an mdBook preprocessor that replaces {{ #treesitter <path>#<query>?<params> }} directives with the code extracted from the referenced source file using tree-sitter queries.

§Directive syntax

{{ #treesitter path/to/file.rs }}
{{ #treesitter path/to/file.rs#query_name }}
{{ #treesitter path/to/file.rs#query_name?param1=val1&param2=val2 }}

The space around the braces is optional:

{{#treesitter path/to/file.rs#doc_comment?name=Foo}}

Modules§

config
Configuration types for the mdbook-treesitter preprocessor.
language
Language registry: maps file extensions to tree-sitter parsers.
query
Query execution: runs either a tree-sitter S-expression query or a jq filter against a source file and returns the matching code text.

Structs§

Directive
A parsed #treesitter directive.
TreesitterPreprocessor
The mdbook-treesitter preprocessor.

Functions§

process_chapter
Replace all {{ #treesitter ... }} directives in content with the extracted code. Directives that fail to resolve are reported as errors.