Skip to main content

Crate fountain

Crate fountain 

Source
Expand description

fountain parses and renders Fountain markdown, which allows you to write screenplays in plain text and render them into beautiful screenplay-formatted documents. This crate currently only implements a subset of the full Fountain spec, but aims to eventually be fully compliant.

§Quick Example

// Parses a plain text Fountain-markup document and outputs HTML.
use fountain;
use nom::error::ErrorKind;

const SCREENPLAY: &str = "\
INT. MESS

The entire crew is seated. Hungrily swallowing huge portions of artificial food. The cat eats \
from a dish on the table.

KANE
First thing I'm going to do when we get back is eat some decent food.
";

// Parse the Fountain-structured plaintext into a fountain::data::Document
let parse_result = fountain::parse_document::<(&str, ErrorKind)>(&SCREENPLAY);
match parse_result {
    Err(e) => eprintln!("Error while parsing the screenplay: {:?}", e),
    Ok(("", parsed)) => {
        eprintln!("Successfully parsed the document");
        println!("{}", parsed.as_html());
    }
    Ok((unparsed, parsed)) => {
        eprintln!("Couldn't parse the entire document. Unparsed section:");
        eprintln!("{}", unparsed);
        println!("{}", parsed.as_html());
    }
}

Modules§

data
Datatypes for storing Fountain documents. If you’d like these types to derive Serialize and Deserialize using serde, please set your dependency on fountain to use the use_serde feature: fountain = { version = <target version>, features = ["use_serde"] }

Functions§

parse_document
Parses a string slice into a Fountain document. Your input string should end in a newline for parsing to succeed.