tree-sitter-markdown


Nametree-sitter-markdown JSON
Version 0.3.2 PyPI version JSON
download
home_pageNone
SummaryMarkdown grammar for tree-sitter
upload_time2024-09-11 13:34:28
maintainerNone
docs_urlNone
authorMDeiml
requires_python>=3.9
licenseMIT
keywords incremental parsing tree-sitter markdown
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tree-sitter-markdown

[![CI][ci]](https://github.com/tree-sitter-grammars/tree-sitter-markdown/actions)
[![discord][discord]](https://discord.gg/w7nTvsVJhm)
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
[![npm][npm]](https://www.npmjs.com/package/@tree-sitter-grammars/tree-sitter-markdown)
[![crates][crates]](https://crates.io/crates/tree-sitter-md)
[![pypi][pypi]](https://pypi.org/project/tree-sitter-markdown/)

A Markdown parser for [tree-sitter].

![screenshot](https://github.com/MDeiml/tree-sitter-markdown/blob/split_parser/contrib/screenshot.png)

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](#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](https://github.github.com/gfm/) | ✓ | Task lists, strikethrough, pipe tables |
| Task lists | `EXTENSION_TASK_LIST` | [link](https://github.github.com/gfm/#task-list-items-extension-) | ✓ |  |
| Strikethrough | `EXTENSION_STRIKETHROUGH` | [link](https://github.github.com/gfm/#strikethrough-extension-) | ✓ |  |
| Pipe tables | `EXTENSION_PIPE_TABLE` | [link](https://github.github.com/gfm/#tables-extension-) | ✓ |  |
| YAML metadata | `EXTENSION_MINUS_METADATA` | [link](https://gohugo.io/content-management/front-matter/) | ✓ |  |
| TOML metadata | `EXTENSION_PLUS_METADATA` | [link](https://gohugo.io/content-management/front-matter/) | ✓ |  |
| Tags | `EXTENSION_TAGS` | [link](https://help.obsidian.md/Editing+and+formatting/Tags#Tag+format) |  |  |
| Wiki Link | `EXTENSION_WIKI_LINK` | [link](https://help.obsidian.md/Linking+notes+and+files/Internal+links) |  |  |

## Usage in Editors

For guides on how to use this parser in a specific editor, refer to that
editor's specific documentation, e.g.
* [neovim](https://github.com/nvim-treesitter/nvim-treesitter)
* [helix](https://docs.helix-editor.com/guides/adding_languages.html)

## 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

[CommonMark Spec]: https://spec.commonmark.org/
[Github flavored markdown]: https://github.github.com/gfm/
[tree-sitter]: https://tree-sitter.github.io/tree-sitter/
[neovim]: https://neovim.io/
[helix]: https://helix-editor.com/
[CONTRIBUTING.md]: https://github.com/MDeiml/tree-sitter-markdown/blob/split_parser/CONTRIBUTING.md
[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter-grammars/tree-sitter-markdown/ci.yml?logo=github&label=CI
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
[npm]: https://img.shields.io/npm/v/%40tree-sitter-grammars%2Ftree-sitter-markdown?logo=npm
[crates]: https://img.shields.io/crates/v/tree-sitter-md?logo=rust
[pypi]: https://img.shields.io/pypi/v/tree-sitter-markdown?logo=pypi&logoColor=ffd242

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tree-sitter-markdown",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "incremental, parsing, tree-sitter, markdown",
    "author": "MDeiml",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/34/4a/bd03a2e1302f1bd223c4df834e3d8c8a3cc37620786dae48be3a253369f1/tree_sitter_markdown-0.3.2.tar.gz",
    "platform": null,
    "description": "# tree-sitter-markdown\n\n[![CI][ci]](https://github.com/tree-sitter-grammars/tree-sitter-markdown/actions)\n[![discord][discord]](https://discord.gg/w7nTvsVJhm)\n[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)\n[![npm][npm]](https://www.npmjs.com/package/@tree-sitter-grammars/tree-sitter-markdown)\n[![crates][crates]](https://crates.io/crates/tree-sitter-md)\n[![pypi][pypi]](https://pypi.org/project/tree-sitter-markdown/)\n\nA Markdown parser for [tree-sitter].\n\n![screenshot](https://github.com/MDeiml/tree-sitter-markdown/blob/split_parser/contrib/screenshot.png)\n\nThe parser is designed to read markdown according to the [CommonMark Spec],\nbut some extensions to the spec from different sources such as [Github flavored\nmarkdown] are also included. These can be toggled on or off at compile time.\nFor specifics see [Extensions](#extensions)\n\n## Goals\n\nEven though this parser has existed for some while and obvious issues are\nmostly solved, there are still lots of inaccuarcies in the output. These stem\nfrom restricting a complex format such as markdown to the quite restricting\ntree-sitter parsing rules.\n\nAs such it is not recommended to use this parser where correctness is\nimportant. The main goal for this parser is to provide syntactical information\nfor syntax highlighting in parsers such as [neovim] and [helix].\n\n## Contributing\n\nAll contributions are welcome. For details refer to [CONTRIBUTING.md].\n\n## Extensions\n\nExtensions can be enabled at compile time through environment variables. Some\nof them are on by default, these can be disabled with the environment variable\n`NO_DEFAULT_EXTENSIONS`.\n\n| Name | Environment variable | Specification | Default | Also enables |\n|:----:|:--------------------:|:-------------:|:-------:|:------------:|\n| Github flavored markdown | `EXTENSION_GFM` | [link](https://github.github.com/gfm/) | \u2713 | Task lists, strikethrough, pipe tables |\n| Task lists | `EXTENSION_TASK_LIST` | [link](https://github.github.com/gfm/#task-list-items-extension-) | \u2713 |  |\n| Strikethrough | `EXTENSION_STRIKETHROUGH` | [link](https://github.github.com/gfm/#strikethrough-extension-) | \u2713 |  |\n| Pipe tables | `EXTENSION_PIPE_TABLE` | [link](https://github.github.com/gfm/#tables-extension-) | \u2713 |  |\n| YAML metadata | `EXTENSION_MINUS_METADATA` | [link](https://gohugo.io/content-management/front-matter/) | \u2713 |  |\n| TOML metadata | `EXTENSION_PLUS_METADATA` | [link](https://gohugo.io/content-management/front-matter/) | \u2713 |  |\n| Tags | `EXTENSION_TAGS` | [link](https://help.obsidian.md/Editing+and+formatting/Tags#Tag+format) |  |  |\n| Wiki Link | `EXTENSION_WIKI_LINK` | [link](https://help.obsidian.md/Linking+notes+and+files/Internal+links) |  |  |\n\n## Usage in Editors\n\nFor guides on how to use this parser in a specific editor, refer to that\neditor's specific documentation, e.g.\n* [neovim](https://github.com/nvim-treesitter/nvim-treesitter)\n* [helix](https://docs.helix-editor.com/guides/adding_languages.html)\n\n## Standalone usage\n\nTo use the two grammars, first parse the document with the block\ngrammar. Then perform a second parse with the inline grammar using\n`ts_parser_set_included_ranges` to specify which parts are inline content.\nThese parts are marked as `inline` nodes. Children of those inline nodes should\nbe excluded from these ranges. For an example implementation see `lib.rs` in\nthe `bindings` folder.\n\n### Usage with WASM\n\nUnfortunately 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\n\n[CommonMark Spec]: https://spec.commonmark.org/\n[Github flavored markdown]: https://github.github.com/gfm/\n[tree-sitter]: https://tree-sitter.github.io/tree-sitter/\n[neovim]: https://neovim.io/\n[helix]: https://helix-editor.com/\n[CONTRIBUTING.md]: https://github.com/MDeiml/tree-sitter-markdown/blob/split_parser/CONTRIBUTING.md\n[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter-grammars/tree-sitter-markdown/ci.yml?logo=github&label=CI\n[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord\n[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix\n[npm]: https://img.shields.io/npm/v/%40tree-sitter-grammars%2Ftree-sitter-markdown?logo=npm\n[crates]: https://img.shields.io/crates/v/tree-sitter-md?logo=rust\n[pypi]: https://img.shields.io/pypi/v/tree-sitter-markdown?logo=pypi&logoColor=ffd242\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Markdown grammar for tree-sitter",
    "version": "0.3.2",
    "project_urls": {
        "Homepage": "https://github.com/tree-sitter-grammars/tree-sitter-markdown"
    },
    "split_keywords": [
        "incremental",
        " parsing",
        " tree-sitter",
        " markdown"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4206303bfad29899625107a19061acc891c922632dafcaa5b142ee62287f537b",
                "md5": "9178313da04aa89794ed4cadae190852",
                "sha256": "2a0d60ee5185fbc20c6f3e7744348956a62f8bc9ae85b574251632e3c2220c77"
            },
            "downloads": -1,
            "filename": "tree_sitter_markdown-0.3.2-cp39-abi3-macosx_10_9_x86_64.whl",
            "has_sig": false,
            "md5_digest": "9178313da04aa89794ed4cadae190852",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 139309,
            "upload_time": "2024-09-11T13:34:18",
            "upload_time_iso_8601": "2024-09-11T13:34:18.971622Z",
            "url": "https://files.pythonhosted.org/packages/42/06/303bfad29899625107a19061acc891c922632dafcaa5b142ee62287f537b/tree_sitter_markdown-0.3.2-cp39-abi3-macosx_10_9_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b47991aff35ff6bb64e49d51223c029eaa0b2695621d6e101c7de2ffeed94f3e",
                "md5": "2748f8ec70574ee2ff05949c71bc4bde",
                "sha256": "0a72f199966380e18f668abb3e9d0a75569c8a292967deefc432282e253f9f84"
            },
            "downloads": -1,
            "filename": "tree_sitter_markdown-0.3.2-cp39-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "2748f8ec70574ee2ff05949c71bc4bde",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 147572,
            "upload_time": "2024-09-11T13:34:19",
            "upload_time_iso_8601": "2024-09-11T13:34:19.995843Z",
            "url": "https://files.pythonhosted.org/packages/b4/79/91aff35ff6bb64e49d51223c029eaa0b2695621d6e101c7de2ffeed94f3e/tree_sitter_markdown-0.3.2-cp39-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ffd3d0cfb6511574033414cb8cb337e0c76484bd58cf3cc4a5378f8a370e646b",
                "md5": "d0926085690725ef1aba5a4a322d5238",
                "sha256": "3555e5732223b030c8b5742fb565b4528566d96700ea7de9a2902e51fb91be21"
            },
            "downloads": -1,
            "filename": "tree_sitter_markdown-0.3.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "d0926085690725ef1aba5a4a322d5238",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 237684,
            "upload_time": "2024-09-11T13:34:21",
            "upload_time_iso_8601": "2024-09-11T13:34:21.632950Z",
            "url": "https://files.pythonhosted.org/packages/ff/d3/d0cfb6511574033414cb8cb337e0c76484bd58cf3cc4a5378f8a370e646b/tree_sitter_markdown-0.3.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c31adae1ae7e875ed7c4c922b688f418dba9ca81344da26866e4e66a52e8426",
                "md5": "4e11129978f7056524050c20c8dfcb4b",
                "sha256": "d7fd68cbbccd917067696952773a553ef4d604017d9332b7a6f6a05549f1c0a3"
            },
            "downloads": -1,
            "filename": "tree_sitter_markdown-0.3.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "4e11129978f7056524050c20c8dfcb4b",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 194563,
            "upload_time": "2024-09-11T13:34:23",
            "upload_time_iso_8601": "2024-09-11T13:34:23.110949Z",
            "url": "https://files.pythonhosted.org/packages/1c/31/adae1ae7e875ed7c4c922b688f418dba9ca81344da26866e4e66a52e8426/tree_sitter_markdown-0.3.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d972b997bf07d9c429747639c1d268acf1e3a4dd8b01db7049603d105705d97b",
                "md5": "8c409b6a9ce7dbba536eed3849b80624",
                "sha256": "a693f0251f13fa925631fdc9e30f2435f5569d1b3b3d2c3d3b24060d3234f98a"
            },
            "downloads": -1,
            "filename": "tree_sitter_markdown-0.3.2-cp39-abi3-musllinux_1_2_aarch64.whl",
            "has_sig": false,
            "md5_digest": "8c409b6a9ce7dbba536eed3849b80624",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 184481,
            "upload_time": "2024-09-11T13:34:24",
            "upload_time_iso_8601": "2024-09-11T13:34:24.456078Z",
            "url": "https://files.pythonhosted.org/packages/d9/72/b997bf07d9c429747639c1d268acf1e3a4dd8b01db7049603d105705d97b/tree_sitter_markdown-0.3.2-cp39-abi3-musllinux_1_2_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc47fe79137abc7b468a0d2dfdb7f7048c51b5fc97f97c7db7fa41b3d164d51e",
                "md5": "829bf5f2d465cc942e46e08d3ac7c2bc",
                "sha256": "507b9d99500dcbeefb069815b689c3dd36892375e878669f98125d0cd0a814a4"
            },
            "downloads": -1,
            "filename": "tree_sitter_markdown-0.3.2-cp39-abi3-musllinux_1_2_x86_64.whl",
            "has_sig": false,
            "md5_digest": "829bf5f2d465cc942e46e08d3ac7c2bc",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 183967,
            "upload_time": "2024-09-11T13:34:25",
            "upload_time_iso_8601": "2024-09-11T13:34:25.500587Z",
            "url": "https://files.pythonhosted.org/packages/dc/47/fe79137abc7b468a0d2dfdb7f7048c51b5fc97f97c7db7fa41b3d164d51e/tree_sitter_markdown-0.3.2-cp39-abi3-musllinux_1_2_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93e63568b87c995fd83d003258f8573016c6c4ba12766cc2b8de43d9f592f85a",
                "md5": "f0a0066b8e9ccaf6adca0beef3362d1f",
                "sha256": "a89a374920d648599d07036e0ec979f54fde684ddaee1bddf406339c51565cbc"
            },
            "downloads": -1,
            "filename": "tree_sitter_markdown-0.3.2-cp39-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "f0a0066b8e9ccaf6adca0beef3362d1f",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 141976,
            "upload_time": "2024-09-11T13:34:26",
            "upload_time_iso_8601": "2024-09-11T13:34:26.647140Z",
            "url": "https://files.pythonhosted.org/packages/93/e6/3568b87c995fd83d003258f8573016c6c4ba12766cc2b8de43d9f592f85a/tree_sitter_markdown-0.3.2-cp39-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69dcae2600354d621abe68baf0417847d543d0752b98f9e1727a6d74c9c7806d",
                "md5": "3f7fcfda7cfd1c39e0e958c67f2a2b73",
                "sha256": "017e7c09c44861f35a4499564ecd0d97a25341905dc9d0dec2e6a38ee4e6b52d"
            },
            "downloads": -1,
            "filename": "tree_sitter_markdown-0.3.2-cp39-abi3-win_arm64.whl",
            "has_sig": false,
            "md5_digest": "3f7fcfda7cfd1c39e0e958c67f2a2b73",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 136424,
            "upload_time": "2024-09-11T13:34:27",
            "upload_time_iso_8601": "2024-09-11T13:34:27.660820Z",
            "url": "https://files.pythonhosted.org/packages/69/dc/ae2600354d621abe68baf0417847d543d0752b98f9e1727a6d74c9c7806d/tree_sitter_markdown-0.3.2-cp39-abi3-win_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "344abd03a2e1302f1bd223c4df834e3d8c8a3cc37620786dae48be3a253369f1",
                "md5": "0d3ff5410d14231a69169fe79581e4d0",
                "sha256": "64501234ae4ce5429551624e2fd675008cf86824bd8b9352223653e39218e753"
            },
            "downloads": -1,
            "filename": "tree_sitter_markdown-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0d3ff5410d14231a69169fe79581e4d0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 251943,
            "upload_time": "2024-09-11T13:34:28",
            "upload_time_iso_8601": "2024-09-11T13:34:28.951492Z",
            "url": "https://files.pythonhosted.org/packages/34/4a/bd03a2e1302f1bd223c4df834e3d8c8a3cc37620786dae48be3a253369f1/tree_sitter_markdown-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-11 13:34:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tree-sitter-grammars",
    "github_project": "tree-sitter-markdown",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tree-sitter-markdown"
}
        
Elapsed time: 0.51805s