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 installCommands
Generate the parser from grammar.js:
bash
npm run generateRun the grammar test suite:
bash
npm run testParse a template file:
bash
npm run parse example.folioGrammar 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:
- The VS Code extension for syntax highlighting
- The Language Server for parsing and analysis
- Any editor with Tree-sitter support
Updating the Grammar
- Edit
grammar.js. - Run
npm run generate. - Run
npm run test. - Update the VS Code extension and LSP with the generated parser.