rustwell 0.3.1

A library for parsing and compiling fountain screenplay scripts.
Documentation
//! This crate is an implementation of the [Fountain](https://fountain.io/) screenplay markup
//! language specification, and acts as a tool for parsing and exporting the *Fountain*
//! language to different kinds of formatted documents, such as `html` and `pdf`.
//!
//! The crate can be used both for the whole compilation process, but also as an intermediary step
//! for parsing *Fountain* text into an abstract syntax tree (AST) that can then be used when
//! constructing new exporters.
//!
//! # Examples
//!
//! ```
//! use rustwell::{Exporter, ExporterExt, HtmlExporter};
//! use rustwell::parse;
//!
//! let script = r#"
//! Title: Example Screenplay
//!
//! INT. HOUSE – DAY
//!
//! Someone is knocking on the door.
//!
//! GUEST
//! (tired)
//! Hey, open up!
//! "#;
//!
//! let parsed = parse(script);
//! let exporter = HtmlExporter { ..Default::default() };
//!
//! exporter.export_to_stdout(&parsed).unwrap()
//! ```

use std::io::Read;

mod export;
mod parser;

pub mod rich_string;
pub mod screenplay;
pub use screenplay::Screenplay;

pub use export::Exporter;
pub use export::ExporterExt;
pub use export::html::HtmlExporter;
pub use export::pdf::A4;
pub use export::pdf::LETTER;
pub use export::pdf::PaperSize;
pub use export::pdf::PdfExporter;

/// Parses a Fountain source string into a [Screenplay] structure.
///
/// Preprocesses the source text by removing
/// comments and normalizing tabs to spaces.
///
/// # Examples
///
/// ```
/// use rustwell::parse;
///
/// let input = r#"
/// Title: Example Screenplay
///
/// INT. ROOM – DAY
/// A man stands alone.
/// "#;
///
/// let screenplay = parse(input);
/// assert!(screenplay.elements.len() > 0);
/// ```
pub fn parse(src: impl AsRef<str>) -> Screenplay {
    parser::parse(src.as_ref())
}

/// Parses a Fountain source file into a [Screenplay] structure.
pub fn parse_reader(mut r: impl Read) -> std::io::Result<Screenplay> {
    let mut src = String::new();
    r.read_to_string(&mut src)?;
    Ok(parser::parse(&src))
}