Skip to content
rsdoielPublic

About

experimental golang package for working with Fountain formatted screenplays.

Topics

Resources

Stars

8 stars

Watchers

2 watching

Forks

Latest commit

 

History

139 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

fountain

fountain is a Go package and three small command line programs for working with Fountain formatted screenplays, the plain text format many screenwriting programs read and write. The package parses a document into title page and script elements, pretty prints it, and renders it as HTML, JSON or YAML.

The package

doc, err := fountain.Parse(src)            // or fountain.ParseFile("script.fountain")
for _, e := range doc.Elements {
    switch e.Type {
    case fountain.SceneHeadingType:
        fmt.Println(e.SceneNumber, e.Content) // 12A INT. KITCHEN - DAY #12A#
    case fountain.BoneyardType:
        fmt.Println(fountain.BoneyardText(e.Content))
    }
}
fmt.Println(doc.String())                  // pretty printed Fountain
fmt.Println(doc.ToHTML())                  // HTML
data, _ := doc.ToJSON()                    // or doc.ToYAML()

A Fountain has a TitlePage and Elements; each Element has a Type (SceneHeadingType, ActionType, CharacterType, DialogueType, ParentheticalType, TransitionType, NoteType, BoneyardType, SectionType, SynopsisType and the rest), a Name, its Content, and, on a scene heading, the SceneNumber.

  • Scene numbers. A heading that ends in a number written between hashes, INT. KITCHEN - DAY #12A#, has SceneNumber "12A". Content keeps the heading as written.
  • Boneyards. Cut material between /* and */, on one line or across several, is one BoneyardType element. BoneyardText returns the text between the delimiters.
  • Output options. The package variables MaxWidth, AsHTMLPage, InlineCSS, LinkCSS, CSS, ShowSection, ShowSynopsis and ShowNotes control String and ToHTML.

The runnable example in example_test.go is the one above in miniature, and is checked by go test.

The programs

fountain2json : a Fountain to JSON converter, useful for building reports. The JSON has the element fields above, scene_number included.

fountainfmt : a Fountain pretty printer

fountain2html : a Fountain to HTML converter

Install

Get a release from GitHub, or see INSTALL.md, which also covers installing from source. To use the package in a Go program:

go get github.com/rsdoiel/fountain

Build and test

You need Go 1.27.3 or later. Pandoc and GNU Make are only needed for the man pages and the website, and cmt (CMTools) only to regenerate version.go, about.md and CITATION.cff from codemeta.json.

make          # build the programs into bin/ and the man pages into man/
make test     # go test ./...
make check    # gofmt -l and go vet; rewrites nothing

get-optional-testdata.bash downloads the larger sample screenplays from fountain.io into testdata/; see testdata.md. make generate runs cmt; make release builds the distribution zips from a committed, pushed tree (it does not run generate), and release.bash then drafts the GitHub release.

Release notes

1.0.3. Boneyards are parsed as BoneyardType elements. A one-line boneyard used to read as Action, and the lines of a multi-line one as Character, Dialogue and Action. Scene headings carry their number in Element.SceneNumber, the JSON output has scene_number, and BoneyardText is new. Go 1.26.4 or later is required. These were added for the knowledge module, which reads Fountain scenes and keeps story metadata in one-line boneyards.

Known limitations

The parser is line based. The open items are in TODO.md: a character line such as DOG in sample-05 is read as dialogue, and parentheticals scattered through dialogue in sample-07 can turn dialogue into Action. A boneyard is written into HTML output as a boneyard element rather than hidden.

Related

  • fdx, osf and scripttool convert between Fountain, Final Draft, Open Screenplay Format and FadeIn.
  • knowledge ingests Fountain files as documents, one section per scene.

Reference materials

fountain is licensed under the GNU Affero General Public License, version 3 or (at your option) any later version; see LICENSE.

About

experimental golang package for working with Fountain formatted screenplays.

Topics

Resources

Stars

8 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages