Skip to content

Tree-sitter Grammar

The tree-sitter-folio-pdf package provides a Tree-sitter grammar for the Folio template language. It powers accurate syntax highlighting and parsing in editors that support Tree-sitter.

Setup

bash
cd tree-sitter-folio-pdf
npm install

Commands

Generate the parser from grammar.js:

bash
npm run generate

Run the grammar test suite:

bash
npm run test

Parse a template file:

bash
npm run parse example.folio

Grammar Coverage

  • Elements: page, column, row, text, heading, table, tr, td, th
  • Page chrome: pageheader, pagefooter, pagenum
  • Control flow: if / else / elseif, foreach
  • Declarations: var, prop
  • Expressions: comparison, logical operators, dot notation
  • Comments: single-line //

Who Uses It

The grammar is used by:

Updating the Grammar

  1. Edit grammar.js.
  2. Run npm run generate.
  3. Run npm run test.
  4. Update the VS Code extension and LSP with the generated parser.

Engineered for teams that care about predictable PDF output.