2 releases

0.7.1 Apr 18, 2021
0.7.0 Apr 18, 2021

#260 in #incremental

26 downloads per month

MIT license

1.5MB
58K SLoC

C 35K SLoC C++ 22K SLoC // 0.0% comments JavaScript 309 SLoC // 0.0% comments Rust 43 SLoC // 0.2% comments

tree-sitter-markdown

npm crates build

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.

Changelog

Install

npm install tree-sitter-markdown tree-sitter

Usage

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

Dependencies

~2.8–4MB
~73K SLoC