Skip to main content

Fountain-Py

CI 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 can render them as HTML.

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 Render Modes: HTML fragments for embedding, full pages with CSS, or raw CSS for custom styling
  • Round-Trip and Export: Write a parsed script back to clean Fountain, or export it to JSON
  • Type-Safe: Built with full type hints and strict mypy compliance
  • Zero Dependencies: Pure Python with no runtime dependencies
  • 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

Fountain-Py is not on PyPI yet (the 0.1.0 release is pending), so install it from source:

pip install git+https://github.com/MasonEgger/fountain-py.git

Once it is published, pip install fountain-py will work.

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.1.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.1.0
File Size Uploaded Provenance
fountain_py-0.1.0.tar.gz 211.6 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 259.4 kB

Release files / fountain_py-0.1.0.tar.gz

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

Download URL fountain_py-0.1.0-py3-none-any.whl
Size 47.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc34ec58c3bfc40d88f5d5f7d6df0cd5eed1e66efef9df4038b4e13a50090ae7
BLAKE2b-256 checksum
How to use checksums
3213f7e0fe76fc76eee3e11a470384ad943f9f07794224c76162f174d90d1d85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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.1.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