Fountain-ts
Fountain-ts is a TypeScript based parser for the screenplay format Fountain. Based on Matt Daly's fountain-js.
Deprecation Notice
The package known as fountain.ts
is being deprecated in favor of fountain-js
. Please visit the fountain-js NPM package for latest versions for this codebase.
Syntax Support
Supports up to v 1.1
of the Fountain syntax.
Currently Fountain-ts supports a limited range of key-value pairs for title pages -
- Title, Credit, Author/s, Source, Notes, Draft date, Date, Contact, Copyright
How To
Fountain-ts behaves as Fountain-js does. Import Fountain
and create a new instance of it.
import { Fountain } from 'fountain.ts';
The output provided by Fountain-ts is an object literal, a Script
interface, of the format: { title: '...', html: { title_page: '...', script: '...' } }
.
An example.
import { Fountain, Script } from 'fountain.ts';
import * as assert from 'assert';
const text = `.OPENING TITLES
> BRICK & STEEL <
> FULL RETIRED <
SMASH CUT TO:`;
let fountain = new Fountain();
let output: Script = fountain.parse(text);
let actual = output.html.script;
const expected = '<h3>OPENING TITLES</h3><p class="centered">BRICK & STEEL <br /> FULL RETIRED</p><h2>SMASH CUT TO:</h2>';
assert.equal(actual, expected);
Parser Tokens
Like Fountain-js, if you want access to the tokens that Fountain-ts generates, simply attach a true
parameter to your parse calls. Requesting tokens adds a tokens property to the output generated by Fountain-ts.
let output: Script = fountain.parse(script, true);
console.log(output.tokens);
The tokens for the Brick & Steel sample found on the Fountain website would look as follows (just a small sample):
[
...,
{ type="scene_heading", text="EXT. BRICK'S PATIO - DAY", scene_number="1"},
{ type="action", text="A gorgeous day. The su...emplating -- something."},
{ type="action", text="The SCREEN DOOR slides ...es with two cold beers."},
{ type="dialogue_begin"},
{ type="character", text="STEEL"},
{ type="dialogue", text="Beer's ready!"},
{ type="dialogue_end"},
{ type="dialogue_begin"},
{ type="character", text="BRICK"},
{ type="dialogue", text="Are they cold?"},
{ type="dialogue_end"},
{ type="page_break"},
{ type="dialogue_begin"},
{ type="character", text="STEEL"},
{ type="dialogue", text="Does a bear crap in the woods?"},
{ type="dialogue_end"},
{ type="action", text="Steel sits. They laugh at the dumb joke."},
{ type="dialogue_begin"},
{ type="character", text="STEEL"},
{ type="parenthetical", text="(beer raised)"},
{ type="dialogue", text="To retirement."},
{ type="dialogue_end"},
{ type="dialogue_begin"},
{ type="character", text="BRICK"},
{ type="dialogue", text="To retirement."},
{ type="dialogue_end"}
...
]
Just like Fountain-js, Fountain-ts attaches some extra tokens, such as 'dialogue_begin'
and 'dialogue_end'
. These are used to block together sections.
In the case of dual dialogue, it allows Fountain-ts to attach a dual
property to blocks of dialogue.