Skip to main content

Fountain-Py

CI PyPI version Python versions License: MIT Code style: ruff

A Python library for parsing Fountain markup, the screenwriting format. Fountain-Py converts Fountain scripts into structured Python objects and renders them as HTML, plain text, Fountain, Final Draft (FDX), PDF, or JSON, from Python or the fountain command line.

Features

  • Full Fountain Support: Parses all Fountain elements including scenes, dialogue, action, transitions, notes, dual dialogue, lyrics, and inline emphasis
  • Validation: Reports structural problems (unclosed comments and notes, orphaned character cues) through a validation API
  • Multiple Output Formats: Renders to HTML (fragment, full page, or raw CSS), plain text, Fountain, Final Draft (FDX), or PDF
  • JSON Interchange: Serializes a parsed script with to_json() and rebuilds it with from_json(), backed by a versioned schema
  • Command-Line Interface: The fountain CLI validates and renders scripts without writing any Python
  • Round-Trip: Writes a parsed script back to clean Fountain, preserving element structure and inline emphasis
  • Type-Safe: Built with full type hints and strict mypy compliance
  • Minimal Dependencies: Pure Python core with no runtime dependencies; PDF export is an optional pdf extra
  • Well-Tested: Unit tests and doctests across every module, with high coverage enforced in CI
  • Modern Python: Supports Python 3.11 through 3.15

Quick Start

Installation

pip install fountain-py

Basic Usage

from fountain import FountainParser
from fountain.renderer import HTMLRenderer

# Parse a Fountain script
parser = FountainParser()
document = parser.parse("""Title: My Screenplay
Author: Jane Writer

INT. COFFEE SHOP - DAY

SARAH enters, looking tired.

SARAH
One large cappuccino, please!
""")

# Access parsed data
print(document.metadata["title"])  # "My Screenplay"
print(document.get_characters())  # ["SARAH"]
print(len(document.elements))  # 3

# Render as HTML fragment (for embedding in web pages)
renderer = HTMLRenderer()
html_fragment = renderer.render(document)

# Render as standalone HTML file with embedded CSS
html_page = renderer.render_page(document)

# Get raw CSS for external stylesheets
css = renderer.get_css()

Rendering Modes

renderer = HTMLRenderer()

# Fragment — no <style> tags, just the screenplay markup
# Use this for embedding in web pages, docs, or CMS systems
fragment = renderer.render(document)

# Full page — self-contained HTML with embedded CSS
# Use this for saving as .html files or previewing
page = renderer.render_page(document)

# Raw CSS — for custom stylesheet integration
# Use this with mkdocs, static site generators, or your own build pipeline
css = renderer.get_css()

Round-Trip Conversion

from fountain.renderer import FountainRenderer

# Convert back to Fountain markup
fountain_renderer = FountainRenderer()
fountain_text = fountain_renderer.render(document)

The round trip preserves element structure and inline emphasis. Scene headings, action, character cues, parentheticals, dialogue, transitions, dual dialogue, lyrics, sections, synopses, and notes all keep their element types through parse(render(parse(text))), and the blank lines that separate structural blocks survive so blocks are not merged on re-parse.

Inline emphasis is re-emitted too. The parser records the bold (**), italic (*), and underline (_) delimiters as formatting spans, and FountainRenderer restores them, so a **bold** word round-trips as **bold**, including nested emphasis and backslash-escaped literals.

Documentation

Full documentation is available at masonegger.github.io/fountain-py.

Development

Setup

git clone https://github.com/MasonEgger/fountain-py.git
cd fountain-py

# Install with development and docs dependencies
just dev

Running Tests

# The gate: lint, format check, mypy strict, and tests (module doctests included)
just check

# Run only the tests
just test

# Run tests with a coverage report
just test-cov

# Run the tests on every supported Python version
just test-all

# Run specific tests
uv run pytest tests/test_parser.py

Code Quality

just fmt          # Format code and auto-fix lint issues (ruff)

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Fountain Format

Fountain is a simple markup syntax for writing, editing and sharing screenplays in plain text. Learn more at fountain.io.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • The Fountain format creators
  • The screenwriting community for feedback and testing

Metadata

Release files for fountain-py 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fountain-py 0.3.0
File Size Uploaded Provenance
fountain_py-0.3.0.tar.gz 276.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fountain-py 0.3.0
File Interpreter ABI Platform
fountain_py-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 339.2 kB

Release files / fountain_py-0.3.0.tar.gz

Download URL fountain_py-0.3.0.tar.gz
Size 276.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9ff3f885a8067c38cf94f54b26af6aa162c812c52d00592968243eb667e925ac
BLAKE2b-256 checksum
How to use checksums
3f65c1474b262b4f39f9af185dfddc5a1bbcd46a720e03aa5c8dc65efc99f0ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fountain_py-0.3.0-py3-none-any.whl

Download URL fountain_py-0.3.0-py3-none-any.whl
Size 62.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85c3777eb7c6adffa4d3b2c54918aed30d860b4d1170a04da9052d1bdabff5be
BLAKE2b-256 checksum
How to use checksums
ce0698242448872e9920b52c068012ff0401f1be5ecac9f6e72b77665857d175
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for fountain-py 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page