1.0.6 • Published 3 years ago

fountainer v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Fountainer

Fountainer is a Javascript CLI tool to convert screenplays written using Fountain syntax into HTML files.


Contents

Installation

To install the CLI globally run the following command.

npm install fountainer --global

To install the CLI for a specific project, run the following command.

npm install fountainer --save

CLI Usage

The CLI tool can be used as follows.

fountainer -i myStory.fountain -o index.html

The tool accepts the following arguments

AliasNameDescriptionDefault
versionShow version number
iinputFilecomplete path to Fountain file
nkeepNotesrender notes from the fountain filefalse
ggitLinerender the draft number by counting the number of commits on the fountain file. This will only work if the file is part of a Git repositoryfalse
llineNumbersrender line numbers corresponding to lines in the fountain file, must be one of "none" - don't print any line numbers, "all" - print all line numbers, "non-empty" - print line numbers only on non-empty lines"none"
ttitlePagerender a title pagetrue
ddebugrender the inferred class on each linefalse
vverboseprint verbose logging to consolefalse
ooutputFilecomplete path to output HTML file (required)
sstylesPathpath to a custom CSS or SCSS file<default SCSS>
ptemplatePathpath to a custom template, can be an EJS or HTML file<default template>
showTemplateprint <default template> to console
showScssprint <default SCSS> file to console
wwatchset this flag to watch inputFile and recompile on change
portapplicable only when watch is set, controls the port on which the compiled file will be served when watching
helpShow help

Javascript API Usage

The tool also exports a javascript library, which can be used as follows.

const fs = require('fs')
const fountainer = require('fountainer')

const parsed = fountainer.parse({ inputFile: 'myStory.fountain' })
const html = fountainer.toHtml(parsed)

fs.writeFileSync('index.html', html)

fountainer.parse(options)

This method parses the input and generates an array of each line of the script.

fountainer.toHtml(parsed, options)

This method generates an HTML string by using the result of the parse function.

options

options for both the functions can have following properties.

{
  inputFile: '',   // path to input file,
  inputString: '', // alternately you can provide the fountain string
  keepNotes: 'inline-notes', // name of class for notes
  gitLine: false,  // applicable only when inputFile is provided,
                   // pulls the git hash and number of commits on the
                   // inputFile and prints it as Draft number
  lineNumbers: 'none', // can be 'none', 'all', 'non-empty' see CLI usage above
  titlePage: true,
  debug: false,
  verbose: false,
  stylesPath: '',  // path to custom CSS/SCSS file
  templatePath: '' // path to custom EJS/HTML file
}

Customizing template and themes

You can start customizing your theme by first copying the default template and theme as follows.

fountainer --showTemplate > template.ejs
fountainer --showScss > styles.scss

Perform all the customization on the template.ejs and styles.scss files as needed, then use your custom template as follows.

fountainer -i story.fountain -p template.ejs -s styles.scss

The template must be an EJS file and will recieve the following object

{
  titlePage, // object containing all the title-page field and value pairs
  lines: [ // an array with the parsed result for each line of the inputFile
    {
      lineNumber, // line number corresponding to input file
      text, // actual text of line 
      name // class name of the line
    }
  ],
  css, // CSS string generated from the --stylesPath
  options // options object provided to the fountainer
}