Documentation
¶
Overview ¶
Package fountain is a Golang package supporting Fountain screenplay markup.
css.go manages setting up CSS for either inline style elements or links.
Package fountain supports encoding/decoding fountain formatted screenplays.
@author R. S. Doiel, <rsdoiel@gmail.com>
Copyright (C) 2017-2026 R. S. Doiel
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Package fountain support encoding/decoding fountain screenplay markup
scrippets.go manages fetching and inlining or generating links to John August's scrippets.css
Index ¶
Examples ¶
Constants ¶
const ( // GeneralTextType - not specific formatting, treat as plain text GeneralTextType = iota // EmptyType An empty line(s), block of whitepace, can occur on title page or script page(s) EmptyType // TitlePageType - something that only happens on the title page. // NOTE: Title page elents have a .Name value which is my best guess about the content. TitlePageType // SceneHeadingType - exists in the script pages, it is for scene headings SceneHeadingType // ActionType - designates an action block in the script page(s) ActionType // CharacterType - designates a CHARACTER heading for dialog CharacterType // DialogueType - holds a block of dialogue DialogueType // ParentheticalType - holds any parenthetical statement after CharacterType and before DialogueType ParentheticalType // TransitionType - scene transition instructions, these are minimal in most scripts now, e.g. FADE IN:, FADE TO BLACK:, THE END. TransitionType // ShotType - Goes in the screen heading line ShotType // LyricType - holds lyrics to be sung LyricType // NoteType - holds a script note NoteType // BoneyardType - blocks of cut material that haven't been removed BoneyardType // SectionType - is a markdown like title/heading, not normally display in output but used for navigation in text SectionType // SynopsisType - used as internal documentation, not normally displayed in output SynopsisType // UnderlineStyle - show underlined, in CSS "text-decoration:underline;" UnderlineStyle // ItalicStyle - show as italics (e.g. <i>, <em> in HTML) ItalicStyle // BoldStyle - show as boldface or strong (e.g. <b>, <strong> in HTML) BoldStyle // AllCapsStyle - will transform the text to uppercase, could also trigger CSS "text-transform: uppercase;" AllCapsStyle // Strikethrough - generates strikethrough in CSS Strikethrough // CenterAlignment - center text or block CenterAlignment // LeftAlignment - left align text or block LeftAlignment // RightAlignment - right align text of block RightAlignment // PageFeed - inject a page feed or <hr> in HTML PageFeed )
const ( // Version number of release Version = "1.0.5" // ReleaseDate, the date version.go was generated ReleaseDate = "2026-11-28" // ReleaseHash, the Git hash when version.go was generated ReleaseHash = "cc3550b" LicenseText = `` /* 34526-byte string literal not displayed */ )
Variables ¶
var ( // MaxWidth used to set width for Fountain text output in String() MaxWidth = 64 // AsHTMLPage if true generate the HTML header and footer blocks AsHTMLPage = false // InlineCSS sets behavior of including style elements with CSS in ToHTML() InlineCSS = false // LinkCSS sets behavior of including link element pointing to CSS file in ToHTML() LinkCSS = false // CSS holds the filename to use generating CSS links or reading // in a customized version of the CSS. Defaults to "fountain.css". CSS = "fountain.css" // ShowSection - preserve section markers in output (e.g. when pretty printing a working draft) ShowSection = false // ShowSynopsis - preserve synopsis in output (e.g. when pretty printing a working draft) ShowSynopsis = false // ShowNotes - preserve notes in output (e.g. when pretty printing a working draft) ShowNotes = false // Pretty Print - will pretty print for output (e.g. when turning into // JSON, use MarshalIndent) PrettyPrint = false )
var ( // SourceCSS is a default CSS to use when rendering SourceCSS = `` /* 3262-byte string literal not displayed */ )
Functions ¶
func BoneyardText ¶ added in v1.0.3
BoneyardText returns the text inside a boneyard element's content, without the /* and */ delimiters and trimmed. Content that is not a boneyard is returned unchanged.
fountain.BoneyardText("/* story: pov=Anna */") // "story: pov=Anna"
func CharacterName ¶ added in v0.0.6
CharacterName takes an element of type Character and trims spaces, removes parenthetical (e.g. `(O.S.)`) and returns a string of the character name(s). NOTE: characters in the form of "JANE AND JOE" will be returned as "JANE AND JOE".
Types ¶
type Element ¶
type Element struct {
Type int `json:"type" yaml:"type"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Content string `json:"content" yaml:"content"`
// SceneNumber is the number written at the end of a scene heading
// ("INT. KITCHEN - DAY #12A#" has "12A"), empty for any other element
// and for a heading with no number. Content keeps the heading as
// written, number included.
SceneNumber string `json:"scene_number,omitempty" yaml:"scene_number,omitempty"`
}
Element holds the parsed token in either the title page of the document or scene list parts.
type Fountain ¶
Fountain is the document container. It is the type returned by Parse() and ParseFile()
screenplay, _ := ParseFile("screenplay.fountain")
fmt.Println(screenplay.String())
func Parse ¶
Parse takes []byte and returns a Fountain struct and error
Example ¶
Parse reads a Fountain document. A scene heading carries its scene number and a boneyard is its own element.
package main
import (
"fmt"
"github.com/rsdoiel/fountain"
)
func main() {
src := []byte("Title: The Long Fire\n\nINT. KITCHEN - DAY #12A#\n\n/* cut: Anna waits */\n\nAnna enters.\n")
doc, err := fountain.Parse(src)
if err != nil {
panic(err)
}
for _, e := range doc.Elements {
switch e.Type {
case fountain.SceneHeadingType:
fmt.Printf("scene %s: %s\n", e.SceneNumber, e.Content)
case fountain.BoneyardType:
fmt.Printf("boneyard: %s\n", fountain.BoneyardText(e.Content))
case fountain.ActionType:
fmt.Printf("action: %s\n", e.Content)
}
}
}
Output: scene 12A: INT. KITCHEN - DAY #12A# boneyard: cut: Anna waits action: Anna enters.
func (*Fountain) ToHTML ¶ added in v0.0.2
ToHTML converts a Fountain document based on the Options prvided. @param opt *Options a populate struct of options this package supports @return string of HTML
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
fountain2html
command
fountain2html is part of fountain, a Go package for Fountain screenplays.
|
fountain2html is part of fountain, a Go package for Fountain screenplays. |
|
fountain2json
command
fountain2json is part of fountain, a Go package for Fountain screenplays.
|
fountain2json is part of fountain, a Go package for Fountain screenplays. |
|
fountainfmt
command
fountainfmt is part of fountain, a Go package for Fountain screenplays.
|
fountainfmt is part of fountain, a Go package for Fountain screenplays. |
|
internal
|
|
|
cli
Package cli holds the command line behavior of fountain2html, fountain2json and fountainfmt so that plain go test covers it.
|
Package cli holds the command line behavior of fountain2html, fountain2json and fountainfmt so that plain go test covers it. |