Crates.io | tree-sitter-markdown |
lib.rs | tree-sitter-markdown |
version | 0.7.1 |
source | src |
created_at | 2021-04-18 07:46:36.939761 |
updated_at | 2021-04-18 12:51:04.035083 |
description | Markdown grammar for tree-sitter |
homepage | |
repository | https://github.com/ikatyang/tree-sitter-markdown |
max_upload_size | |
id | 386039 |
size | 1,839,150 |
Markdown (CommonMark Spec v0.29-gfm) grammar for tree-sitter
Note: This grammar is based on the assumption that link label matchings will never fail since reference links can come before their reference definitions, which causes it hard to do incremental parsing without this assumption.
npm install tree-sitter-markdown tree-sitter
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)))))
MIT © Ika