A tree-sitter parser for .fountain files with hierarchical parsing support for proper code outlining.
- Complete Fountain Spec: Full implementation of the Fountain 1.1 specification
- Hierarchical AST: Section blocks contain scene blocks, scene blocks contain dialogue/action
- All Elements: Scenes, sections, dialogue, action, transitions, notes, boneyard, synopses, lyrics, centered text, page breaks, title pages
- Forced Elements: Support for forced scene headings (
.HEADING), transitions (>TRANSITION), character names (@CHARACTER), and action (!ACTION) - Dual Dialogue: Character cues with
^marker - Emphasis: Bold, italic, underline, and bold-italic
- Title Pages: Multi-line fields with continuation support
Install the Fountain extension from the Zed extensions gallery:
- Open Zed
- Go to Extensions (Cmd+Shift+X / Ctrl+Shift+X)
- Search for "Fountain"
- Click Install
Features include syntax highlighting, hierarchical outline view (sections → scenes → dialogue), smart indentation, and bracket matching.
Run the unit tests using Node.js built-in test runner:
npm testThis will run all fixture-based tests in test/fixtures/.
Alternatively, run the tree-sitter corpus tests:
npm run test:tree-sitterTo add a new test:
- Create a
.fountainfile intest/fixtures/with your test content - Generate the expected AST by running:
node test/generate-fixtures.jsThis will create a .json file with the complete AST structure for each .fountain file.
Alternatively, you can manually create the JSON file with the expected AST structure:
{
"type": "document",
"children": [
{
"type": "scene_heading",
"children": [
{"type": "scene_start", "children": []},
{"type": "description", "children": []}
]
},
{
"type": "action",
"children": [
{"type": "line", "children": []}
]
}
]
}The test runner will automatically discover and run your new test on the next npm test run. Tests perform deep AST comparison, verifying the complete tree structure.