https://github.com/ikatyang/tree-sitter-markdown
Markdown grammar for tree-sitter
https://github.com/ikatyang/tree-sitter-markdown
grammar markdown tree-sitter
Last synced: 17 days ago
JSON representation
Markdown grammar for tree-sitter
- Host: GitHub
- URL: https://github.com/ikatyang/tree-sitter-markdown
- Owner: ikatyang
- License: mit
- Created: 2019-09-30T08:38:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-27T21:35:08.000Z (over 1 year ago)
- Last Synced: 2024-10-29T22:08:47.196Z (6 months ago)
- Topics: grammar, markdown, tree-sitter
- Language: C++
- Homepage: https://ikatyang.github.io/tree-sitter-markdown
- Size: 1.51 MB
- Stars: 183
- Watchers: 10
- Forks: 29
- Open Issues: 32
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# tree-sitter-markdown
[](https://www.npmjs.com/package/tree-sitter-markdown)
[](https://crates.io/crates/tree-sitter-markdown)
[](https://travis-ci.com/ikatyang/tree-sitter-markdown/builds)Markdown ([CommonMark Spec v0.29-gfm](https://github.github.com/gfm/)) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)
_Note: This grammar is based on the assumption that **[link label matchings](https://github.github.com/gfm/#matches) will never fail** since reference links can come before their reference definitions, which causes it hard to do incremental parsing without this assumption._
[Changelog](https://github.com/ikatyang/tree-sitter-markdown/blob/master/CHANGELOG.md)
## Install
```sh
npm install tree-sitter-markdown tree-sitter
```## Usage
```js
const Parser = require("tree-sitter");
const Markdown = require("tree-sitter-markdown");const parser = new Parser();
parser.setLanguage(Markdown);const sourceCode = `
# foo
- bar
baz
`;const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());
// (document
// (atx_heading
// (atx_heading_marker)
// (heading_content
// (text)))
// (tight_list
// (list_item
// (list_marker)
// (indented_code_block
// (text))
// (paragraph
// (text)))))
```## License
MIT © [Ika](https://github.com/ikatyang)