Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fountain.ts

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fountain.ts

A Typescript based parser for the screenplay format Fountain. Source originally from Matt Daly's fountain.js

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Fountain-ts

Fountain-ts is a TypeScript based parser for the screenplay format Fountain. Based on Matt Daly's fountain-js.

Syntax Support

Supports most of the Fountain syntax. Based on the latest version of fountain-js.

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';

The output provided by Fountain-ts is an object literal of the format { title: '...', html: { title_page: '...', script: '...' } }.

An example.

import { Fountain, Script } from 'fountain';
import * as assert from 'assert';

let text = `.OPENING TITLES

            > BRICK & STEEL <
            > FULL RETIRED <

            SMASH CUT TO:`;
        
let fountain = new Fountain();

let output: Script = fountain.parse(text),
    actual: string = 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-js 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.io 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 dialogue it allows Fountain-ts to attach a dual dialogue property to blocks of dialogue.

Keywords

FAQs

Package last updated on 21 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc