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 inaccuarcies 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.3.2.tar.gz (251.9 kB view details)

Uploaded Source

Built Distributions

tree_sitter_markdown-0.3.2-cp39-abi3-win_arm64.whl (136.4 kB view details)

Uploaded CPython 3.9+ Windows ARM64

tree_sitter_markdown-0.3.2-cp39-abi3-win_amd64.whl (142.0 kB view details)

Uploaded CPython 3.9+ Windows x86-64

tree_sitter_markdown-0.3.2-cp39-abi3-musllinux_1_2_x86_64.whl (184.0 kB view details)

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

tree_sitter_markdown-0.3.2-cp39-abi3-musllinux_1_2_aarch64.whl (184.5 kB view details)

Uploaded CPython 3.9+ musllinux: musl 1.2+ ARM64

tree_sitter_markdown-0.3.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (194.6 kB view details)

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

tree_sitter_markdown-0.3.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (237.7 kB view details)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ ARM64

tree_sitter_markdown-0.3.2-cp39-abi3-macosx_11_0_arm64.whl (147.6 kB view details)

Uploaded CPython 3.9+ macOS 11.0+ ARM64

tree_sitter_markdown-0.3.2-cp39-abi3-macosx_10_9_x86_64.whl (139.3 kB view details)

Uploaded CPython 3.9+ macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: tree_sitter_markdown-0.3.2.tar.gz
  • Upload date:
  • Size: 251.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.6

File hashes

Hashes for tree_sitter_markdown-0.3.2.tar.gz
Algorithm Hash digest
SHA256 64501234ae4ce5429551624e2fd675008cf86824bd8b9352223653e39218e753
MD5 0d3ff5410d14231a69169fe79581e4d0
BLAKE2b-256 344abd03a2e1302f1bd223c4df834e3d8c8a3cc37620786dae48be3a253369f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_markdown-0.3.2-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 017e7c09c44861f35a4499564ecd0d97a25341905dc9d0dec2e6a38ee4e6b52d
MD5 3f7fcfda7cfd1c39e0e958c67f2a2b73
BLAKE2b-256 69dcae2600354d621abe68baf0417847d543d0752b98f9e1727a6d74c9c7806d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_markdown-0.3.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a89a374920d648599d07036e0ec979f54fde684ddaee1bddf406339c51565cbc
MD5 f0a0066b8e9ccaf6adca0beef3362d1f
BLAKE2b-256 93e63568b87c995fd83d003258f8573016c6c4ba12766cc2b8de43d9f592f85a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_markdown-0.3.2-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 507b9d99500dcbeefb069815b689c3dd36892375e878669f98125d0cd0a814a4
MD5 829bf5f2d465cc942e46e08d3ac7c2bc
BLAKE2b-256 dc47fe79137abc7b468a0d2dfdb7f7048c51b5fc97f97c7db7fa41b3d164d51e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_markdown-0.3.2-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a693f0251f13fa925631fdc9e30f2435f5569d1b3b3d2c3d3b24060d3234f98a
MD5 8c409b6a9ce7dbba536eed3849b80624
BLAKE2b-256 d972b997bf07d9c429747639c1d268acf1e3a4dd8b01db7049603d105705d97b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_markdown-0.3.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7fd68cbbccd917067696952773a553ef4d604017d9332b7a6f6a05549f1c0a3
MD5 4e11129978f7056524050c20c8dfcb4b
BLAKE2b-256 1c31adae1ae7e875ed7c4c922b688f418dba9ca81344da26866e4e66a52e8426

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_markdown-0.3.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3555e5732223b030c8b5742fb565b4528566d96700ea7de9a2902e51fb91be21
MD5 d0926085690725ef1aba5a4a322d5238
BLAKE2b-256 ffd3d0cfb6511574033414cb8cb337e0c76484bd58cf3cc4a5378f8a370e646b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_markdown-0.3.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0a72f199966380e18f668abb3e9d0a75569c8a292967deefc432282e253f9f84
MD5 2748f8ec70574ee2ff05949c71bc4bde
BLAKE2b-256 b47991aff35ff6bb64e49d51223c029eaa0b2695621d6e101c7de2ffeed94f3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_markdown-0.3.2-cp39-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2a0d60ee5185fbc20c6f3e7744348956a62f8bc9ae85b574251632e3c2220c77
MD5 9178313da04aa89794ed4cadae190852
BLAKE2b-256 4206303bfad29899625107a19061acc891c922632dafcaa5b142ee62287f537b

See more details on using hashes here.

Supported by

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