Tree-sitter grammar for Markdoc with multi-language bindings and editor highlighting support.
- Frontmatter (YAML) blocks
- Markdoc tags and inline expressions
- Fenced code blocks with info strings and attributes
- Headings, lists, blockquotes, and thematic breaks
- Inline formatting (emphasis, strong, links, images, code)
- HTML blocks and comments
- Node.js (for the Tree-sitter CLI via npm) or Rust (for cargo installs)
- Tree-sitter CLI
npm install -g tree-sitter-cliGenerate the parser from grammar.js:
tree-sitter generateRun the corpus tests in test/corpus:
tree-sitter testOpen the playground with the local parser:
tree-sitter playgroundThis project ships bindings for:
- C
- Go
- Node.js
- Python
- Rust
- Swift
See bindings/ for language-specific packages.
Syntax highlighting queries live in queries/highlights.scm.
The notes/ folder collects design references and development logs:
notes/markdoc.ebnfis a hand-maintained grammar sketch used to reason about rules and intended structure. It is not generated and is not the source of truth. When updating the grammar, update the EBNF sketch first to validate the shape of the change, then apply the equivalent updates ingrammar.js.notes/asciidoc_grammar_reference.jsandnotes/asciidoc_scanner_reference.care reference materials used to compare grammar and scanner patterns.notes/command-output.mdrecords diagnostic command output during parser verification.
MIT