Thanks to visit codestin.com
Credit goes to github.com

Skip to content

trieloff/tree-sitter-fountain

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tree-sitter-fountain

CI discord matrix

A tree-sitter parser for .fountain files with hierarchical parsing support for proper code outlining.

Features

  • 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

Editor Support

Zed Editor

Install the Fountain extension from the Zed extensions gallery:

  1. Open Zed
  2. Go to Extensions (Cmd+Shift+X / Ctrl+Shift+X)
  3. Search for "Fountain"
  4. Click Install

Features include syntax highlighting, hierarchical outline view (sections → scenes → dialogue), smart indentation, and bracket matching.

Testing

Running Tests

Run the unit tests using Node.js built-in test runner:

npm test

This will run all fixture-based tests in test/fixtures/.

Alternatively, run the tree-sitter corpus tests:

npm run test:tree-sitter

Creating New Tests

To add a new test:

  1. Create a .fountain file in test/fixtures/ with your test content
  2. Generate the expected AST by running:
node test/generate-fixtures.js

This 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.

References

About

Fountain grammar for tree-sitter.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 71.8%
  • C 24.2%
  • Tree-sitter Query 4.0%