tree-sitter-markdown
A Markdown parser for tree-sitter.
The parser is designed to read markdown according to the CommonMark Spec, but some extensions to the spec from different sources such as Github flavored markdown are also included. These can be toggled on or off at compile time. For specifics see Extensions
Goals
Even though this parser has existed for some while and obvious issues are mostly solved, there are still lots of inaccuracies in the output. These stem from restricting a complex format such as markdown to the quite restricting tree-sitter parsing rules.
As such it is not recommended to use this parser where correctness is important. The main goal for this parser is to provide syntactical information for syntax highlighting in parsers such as neovim and helix.
Contributing
All contributions are welcome. For details refer to CONTRIBUTING.md.
Extensions
Extensions can be enabled at compile time through environment variables. Some
of them are on by default, these can be disabled with the environment variable
NO_DEFAULT_EXTENSIONS.
| Name | Environment variable | Specification | Default | Also enables |
|---|---|---|---|---|
| Github flavored markdown | EXTENSION_GFM |
link | ✓ | Task lists, strikethrough, pipe tables |
| Task lists | EXTENSION_TASK_LIST |
link | ✓ | |
| Strikethrough | EXTENSION_STRIKETHROUGH |
link | ✓ | |
| Pipe tables | EXTENSION_PIPE_TABLE |
link | ✓ | |
| YAML metadata | EXTENSION_MINUS_METADATA |
link | ✓ | |
| TOML metadata | EXTENSION_PLUS_METADATA |
link | ✓ | |
| Tags | EXTENSION_TAGS |
link | ||
| Wiki Link | EXTENSION_WIKI_LINK |
link |
Usage in Editors
For guides on how to use this parser in a specific editor, refer to that editor's specific documentation, e.g.
Standalone usage
To use the two grammars, first parse the document with the block
grammar. Then perform a second parse with the inline grammar using
ts_parser_set_included_ranges to specify which parts are inline content.
These parts are marked as inline nodes. Children of those inline nodes should
be excluded from these ranges. For an example implementation see lib.rs in
the bindings folder.
Usage with WASM
Unfortunately using this parser with WASM/web-tree-sitter does not work out of the box at the moment. This is because the parser uses some C functions that are not exported by tree-sitter by default. To fix this you can statically link the parser to tree-sitter. See also https://github.com/tree-sitter/tree-sitter/issues/949, https://github.com/MDeiml/tree-sitter-markdown/issues/126, and https://github.com/MDeiml/tree-sitter-markdown/issues/93
Metadata
Release files for tree-sitter-markdown 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tree_sitter_markdown-0.5.1.tar.gz | 250.1 kB | Details |
Built distributions (wheels)
Total release size: 1.6 MB
Release files / tree_sitter_markdown-0.5.1.tar.gz
| Download URL | tree_sitter_markdown-0.5.1.tar.gz |
|---|---|
| Size | 250.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c69d7270a7e09be8988ced44584c09a6a4f541cea0dc394dd1c1a5ac3b5601d
|
|
BLAKE2b-256 checksum How to use checksums |
9a878f705d8f99337c8a691bcc8c22d89ddd323eb2b860a78ae2e894b9f7ade1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / tree_sitter_markdown-0.5.1-cp39-abi3-win_arm64.whl
| Download URL | tree_sitter_markdown-0.5.1-cp39-abi3-win_arm64.whl |
|---|---|
| Size | 137.2 kB |
| Tags | CPython 3.9 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
2296ef53a757d8f5b848616706d0518e04d487bc7748bd05755d4a3a65711542
|
|
BLAKE2b-256 checksum How to use checksums |
93f5327dd7fa42ae39796a8853685c40a8ac968585260094c581047270cbc851
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / tree_sitter_markdown-0.5.1-cp39-abi3-win_amd64.whl
| Download URL | tree_sitter_markdown-0.5.1-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 142.5 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b1b0e4cbcf5a7b85005f1e9266fc2ed9b649b41a6048f3b1abae3612368d97a6
|
|
BLAKE2b-256 checksum How to use checksums |
b6ca423600960b91c3aba6f2202ad4c430b5401e652d51a73a59769375c2b4ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_x86_64.whl
| Download URL | tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 184.9 kB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b8a8a04a5d942c177cc590ec40074fcf3658f3a7c0a3388a8575990003665d8c
|
|
BLAKE2b-256 checksum How to use checksums |
8cc88218482d56b78755cdc20816a28754145cb1767e1e7e0ddde5988547ab86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_aarch64.whl
| Download URL | tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 185.5 kB |
| Tags | CPython 3.9 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
13da82db04cec7910b6afd4a67d02da9ef402df8d56fc6ed85e00584af1730ee
|
|
BLAKE2b-256 checksum How to use checksums |
cbd11f2ba1ae11568639f133c45c7a697e4e9277d6cc26a66c0caee62c11d1c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 187.6 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c0b2fde19e692bb90e300d9788887528c624b659c794de6337f8193396de4399
|
|
BLAKE2b-256 checksum How to use checksums |
a8c1994001c5a51d09e9da7236e01a855d3d49437a47fa8669f1d5e9ed60e64f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 187.9 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
727242a70c46222092eba86c102301646f21ba32aee221f4b1f70e2020755e81
|
|
BLAKE2b-256 checksum How to use checksums |
24d54152d00829c8643243f65b67a5485248661824f15e1868e14e54f03c2069
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / tree_sitter_markdown-0.5.1-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | tree_sitter_markdown-0.5.1-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 147.5 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1ec4cc5d7b0d188bad22247501ab13663bb1bf1a60c2c020a22877fabce8daa9
|
|
BLAKE2b-256 checksum How to use checksums |
6d9b65eb5e6a8d7791174644854437d35849d9b4e4ed034d54d2c78810eaf1a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / tree_sitter_markdown-0.5.1-cp39-abi3-macosx_10_9_x86_64.whl
| Download URL | tree_sitter_markdown-0.5.1-cp39-abi3-macosx_10_9_x86_64.whl |
|---|---|
| Size | 139.7 kB |
| Tags | CPython 3.9 abi3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
f00ce3f48f127377983859fcb93caf0693cbc7970f8c41f1e2bd21e4d56bdfd8
|
|
BLAKE2b-256 checksum How to use checksums |
7773b5f88217a526f61080ddd71d554cff6a01ea23fffa584ad9de41ee8d1fe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|