Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.

wildwinter/fountain-py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fountain Parser

Now Obsolete - Unmaintained!

This project is now unmaintained.

I have released fountain-tools, a new set of parsers written from scratch in Python, Javascript, C# and C++. You can find them here: fountain-tools.

About

NOTE: Forked from fountain to add support for Fountain's built-in markup styling.

This Python script is a Fountain script parser, which converts .fountain files to Python objects.

Install

  1. Make a pull request of this repo
  2. Go into the repo-dir on your machine
  3. sudo python3 setup.py install

Usage

from fountain import fountain

fount = fountain.Fountain(STRING)

This will make fount into a Fountain object with fields called metadata and elements.

Each object in elements is a FountainElement which has an element_type drawn from the enum Element - for example:

Element.CHARACTER = character header
Element.PARENTHETICAL = v/o direction instruction
Element.DIALOGUE = line of dialogue

See the fountain reference for more info.

You iterate through elements like so:

from fountain import fountain

fount = fountain.Fountain(STRING)

for element in fount.elements:
    print(element.element_text)

Scenes

This version adds a list of scenes, like so:

from fountain import fountain

fount = fountain.Fountain(STRING)

for scene in fount.scenes:
    for element in scene.elements:
        print(element.element_text)

The first element of scene.elements is always the scene header itself.

Style Markup

This version supports simple bold, italic, and underline markup.

Symbols

*italic*
**bold**
***bolditalic***
_underline_
_underlined and **also bold**_

It adds the method split_to_chunks() to FountainElement.

Optionally you can call it on an element to scan the text and break it into FountainChunk objects.

These chunks each consist of a text element, and whether italic, bool, or underline is true for that element.

from fountain import fountain

fount = fountain.Fountain(STRING)

for element in fount.elements:
    
    # For these two types we want to care about markup...
    if (element.element_type == fountain.Element.DIALOGUE
        or element.element_type == fountain.Element.ACTION):

        chunks = element.split_to_chunks()
        for chunk in chunks:
            some_dummy_font_setup(
                bold = chunk.bold, 
                italic = chunk.italic,
                underline = chunk.underline)
            print_the_text(chunk.text)

        print_new_line()

    # Otherwise
    else:
        print_the_text(element.element_text)
        print_new_line()
        

About

A python Fountain script parser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%