fountain

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: AGPL-3.0 Imports: 12 Imported by: 7

README

fountain

fountain is an experimental Golang package for working with Fountain formatted Screenplay documents. It provides a parser, pretty prints using the String func and has an HTML renderer. fountain format is supported by many programs (see list at fountain.io).

This package also includes a demonstration command line programs

fountain2json : A fountain to JSON converter (useful for building reports)

fountainfmt : A fountain document pretty printer

fountain2html : A fountain to HTML converter

Reference materials

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>

BSD 2-Clause License

Copyright (c) 2019, R. S. Doiel All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Package fountain support encoding/decoding fountain screenplay markup

scrippets.go manages fetching and inlining or generating links to John August's scrippets.css

Index

Constants

View Source
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
)
View Source
const (
	// Version number of release
	Version = "1.0.2"

	// ReleaseDate, the date version.go was generated
	ReleaseDate = "2024-05-20"

	// ReleaseHash, the Git hash when version.go was generated
	ReleaseHash = "494f1e1"

	LicenseText = `` /* 33747-byte string literal not displayed */

)

Variables

View Source
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
)
View Source
var (
	// SourceCSS is a default CSS to use when rendering
	SourceCSS = `` /* 3262-byte string literal not displayed */

)

Functions

func CharacterName added in v0.0.6

func CharacterName(element *Element) string

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".

func FmtHelp added in v1.0.1

func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string

FmtHelp lets you process a text block with simple curly brace markup.

func Run added in v0.0.2

func Run(input []byte) ([]byte, error)

Run takes a byte split and returns an HTML fragment appropriate to use as a Scrippet with John Augusts' CSS https://fountain.io/_css/scrippets.css

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"`
}

Element holds the parsed token in either the title page of the document or scene list parts.

func (*Element) String

func (element *Element) String() string

String() considers elem.Type and formatting output as string

func (*Element) ToHTML added in v0.0.2

func (element *Element) ToHTML() string

ToHTML considers elem.Type and formatting output

func (*Element) TypeName

func (element *Element) TypeName() string

TypeName returns the string describing the type of Fountain Element.

type Fountain

type Fountain struct {
	TitlePage []*Element
	Elements  []*Element
}

Fountain is the document container. It is the type returned by Parse() and ParseFile()

screenplay, _ := ParseFile("screenplay.fountain")
fmt.Println(screenplay.String())

func Parse

func Parse(src []byte) (*Fountain, error)

Parse takes []byte and returns a Fountain struct and error

func ParseFile

func ParseFile(fname string) (*Fountain, error)

ParseFile takes a filename and returns a Fountain struct and error

func (*Fountain) String

func (doc *Fountain) String() string

String return a Fountain formatted document as a string

func (*Fountain) ToHTML added in v0.0.2

func (doc *Fountain) ToHTML() string

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

func (*Fountain) ToJSON added in v0.0.3

func (doc *Fountain) ToJSON() ([]byte, error)

ToJSON renders a Fountain type documents into a JSON serialized data structure.

func (*Fountain) ToYAML added in v1.0.1

func (doc *Fountain) ToYAML() ([]byte, error)

ToYAML renders a Fountain type document into a YAML serialized data structure.

Directories

Path Synopsis
cmd
fountain2html
fountain2html converts a Fountain File into an HTML fragement suitable for including like a scrippet.
fountain2html converts a Fountain File into an HTML fragement suitable for including like a scrippet.
fountain2json
fountain2json parses a fountain file and returns a JSON representation.
fountain2json parses a fountain file and returns a JSON representation.
fountainfmt
fountainfmt pretty prints a fountain file.
fountainfmt pretty prints a fountain file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL