egasimus / tree-sitter-markdown

Markdown grammar for tree-sitter

Home Page:https://ikatyang.github.io/tree-sitter-markdown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Markdown grammar for tree-sitter

https://ikatyang.github.io/tree-sitter-markdown

License:MIT License


Languages

Language:C++ 96.1%Language:JavaScript 3.4%Language:Rust 0.4%Language:Shell 0.0%