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.10 through 3.14

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 && uv sync --group docs

Running Tests

# Run comprehensive quality checks (tests, coverage, doctests, lint, type check)
just test

# Run only unit tests
just unit-test

# Run tests with coverage
just unit-test-cov

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

Code Quality

just lint         # Lint check (ruff)
just format       # Format code (ruff)
just type-check   # Type checking (mypy strict)

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.2.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.2.0
File Size Uploaded Provenance
fountain_py-0.2.0.tar.gz 220.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 282.8 kB

Release files / fountain_py-0.2.0.tar.gz

Download URL fountain_py-0.2.0.tar.gz
Size 220.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f62555ab5352dd1adb8a2b2dc505c6210e646e22003afb2f570fefc2c5360685
BLAKE2b-256 checksum
How to use checksums
c28a91369acb034a015c6d9cb25cd4aec27e9281f894335f052def0664eaa170
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","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.2.0-py3-none-any.whl

Download URL fountain_py-0.2.0-py3-none-any.whl
Size 62.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec372aa72036ac668f17dfd16113710cc1727fad78cf8c1d97d488ddb261e240
BLAKE2b-256 checksum
How to use checksums
94f17c469cdfa5d70b1af32ee2a0fea54003a5f09723afc0e6fc7efa9d827142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","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.2.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