Skip to main content

Markdown grammar for tree-sitter

Project description

tree-sitter-markdown

CI discord matrix npm crates pypi

A Markdown parser for tree-sitter.

screenshot

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_markdown-0.5.1.tar.gz (250.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tree_sitter_markdown-0.5.1-cp39-abi3-win_arm64.whl (137.2 kB view details)

Uploaded CPython 3.9+Windows ARM64

tree_sitter_markdown-0.5.1-cp39-abi3-win_amd64.whl (142.5 kB view details)

Uploaded CPython 3.9+Windows x86-64

tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_x86_64.whl (184.9 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_aarch64.whl (185.5 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (187.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (187.9 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

tree_sitter_markdown-0.5.1-cp39-abi3-macosx_11_0_arm64.whl (147.5 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

tree_sitter_markdown-0.5.1-cp39-abi3-macosx_10_9_x86_64.whl (139.7 kB view details)

Uploaded CPython 3.9+macOS 10.9+ x86-64

File details

Details for the file tree_sitter_markdown-0.5.1.tar.gz.

File metadata

  • Download URL: tree_sitter_markdown-0.5.1.tar.gz
  • Upload date:
  • Size: 250.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tree_sitter_markdown-0.5.1.tar.gz
Algorithm Hash digest
SHA256 6c69d7270a7e09be8988ced44584c09a6a4f541cea0dc394dd1c1a5ac3b5601d
MD5 1d3b0847a7994331731c2401feea86a2
BLAKE2b-256 9a878f705d8f99337c8a691bcc8c22d89ddd323eb2b860a78ae2e894b9f7ade1

See more details on using hashes here.

File details

Details for the file tree_sitter_markdown-0.5.1-cp39-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_markdown-0.5.1-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 2296ef53a757d8f5b848616706d0518e04d487bc7748bd05755d4a3a65711542
MD5 73710c3d82e07f77cfed37447b3b2bfb
BLAKE2b-256 93f5327dd7fa42ae39796a8853685c40a8ac968585260094c581047270cbc851

See more details on using hashes here.

File details

Details for the file tree_sitter_markdown-0.5.1-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_markdown-0.5.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b1b0e4cbcf5a7b85005f1e9266fc2ed9b649b41a6048f3b1abae3612368d97a6
MD5 03039d269effea03d92b7e1b7251773d
BLAKE2b-256 b6ca423600960b91c3aba6f2202ad4c430b5401e652d51a73a59769375c2b4ea

See more details on using hashes here.

File details

Details for the file tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b8a8a04a5d942c177cc590ec40074fcf3658f3a7c0a3388a8575990003665d8c
MD5 7bf9ba87e786a52fa7a09c83a2c4033c
BLAKE2b-256 8cc88218482d56b78755cdc20816a28754145cb1767e1e7e0ddde5988547ab86

See more details on using hashes here.

File details

Details for the file tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_markdown-0.5.1-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 13da82db04cec7910b6afd4a67d02da9ef402df8d56fc6ed85e00584af1730ee
MD5 9f9f21dab4739519ba48360adce81274
BLAKE2b-256 cbd11f2ba1ae11568639f133c45c7a697e4e9277d6cc26a66c0caee62c11d1c2

See more details on using hashes here.

File details

Details for the file tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c0b2fde19e692bb90e300d9788887528c624b659c794de6337f8193396de4399
MD5 c993eb595960c14d54ae9ffcc7587b56
BLAKE2b-256 a8c1994001c5a51d09e9da7236e01a855d3d49437a47fa8669f1d5e9ed60e64f

See more details on using hashes here.

File details

Details for the file tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_markdown-0.5.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 727242a70c46222092eba86c102301646f21ba32aee221f4b1f70e2020755e81
MD5 74072a1c6d7d16a2ab529066cd6a68ca
BLAKE2b-256 24d54152d00829c8643243f65b67a5485248661824f15e1868e14e54f03c2069

See more details on using hashes here.

File details

Details for the file tree_sitter_markdown-0.5.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_markdown-0.5.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1ec4cc5d7b0d188bad22247501ab13663bb1bf1a60c2c020a22877fabce8daa9
MD5 d57d222c4319f7c0735689829f8f1a13
BLAKE2b-256 6d9b65eb5e6a8d7791174644854437d35849d9b4e4ed034d54d2c78810eaf1a6

See more details on using hashes here.

File details

Details for the file tree_sitter_markdown-0.5.1-cp39-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_markdown-0.5.1-cp39-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f00ce3f48f127377983859fcb93caf0693cbc7970f8c41f1e2bd21e4d56bdfd8
MD5 528c97a6aecf6c689e33820f26ec6d12
BLAKE2b-256 7773b5f88217a526f61080ddd71d554cff6a01ea23fffa584ad9de41ee8d1fe5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page