Giter Club home page Giter Club logo

ftn2xml's Introduction

Fountain Screenplay Processor (ftn2xml)

This library converts Fountain screenplay documents into XML-style documents with tags that can be converted to other markup languages, like HTML or FDX. Some command-line utilities are provided to demonstrate use, including PDF conversion using PoDoFo.

Overview

I needed a fountain parser for a Geany plugin. For performance, I wanted a parser written in a compiled language, but nearly all existing (open-source) Fountain parsers are written in scripting languages. The ones that aren't are either difficult (for me) to use or were incomplete. So I was "forced" to write my own.

Calling this a "parser" would be generous since I do not recall how to write a proper parser. Fortunately, the elements of a screenplay are generally identifiable on a line-by-line basis. So this library works by:

  • Identifying the type of each line: Scene Header, Transition, Action, Character, Parenthetical, Speech.
  • Using regular expressions to find bold, italics, and underline formatting.

The main complication to this method is dual dialog. When encountering a dual-dialog marker (^), the processor has to go back to modify the most-recently identified dialog node.

Fountain syntax

A detailed description of standard Fountain is available at Fountain.io. This processor recognizes a modified syntax, which is described at Fountain Syntax.

Usage (command line)

Some basic command line utilities are provided. More details are contained in the --help output.

  • ftn2xml – Convert to native XML-style format.
  • ftn2html – Convert to native HTML-style format.
  • ftn2pdf – Export to PDF using PoDoFo library.
  • ftn2fdx – Convert into Final Draft document.

Usage (source code)

  1. Compile as a library or include the files in your project.

  2. #include "fountain.h"

  3. Call a function to convert the script into the desired format:

    • ftn2xml() – Convert to native XML-style format.
    • ftn2html() – Convert to native HTML-style format.
    • ftn2pdf() – Export to PDF using podofo library.
    • ftn2fdx() – Convert into Final Draft document.
    • ftn2screenplain() – Convert into HTML similar to those produced by screenplain.
    • ftn2textplay() – Convert into HTML similar to those produced by textplay.

Requirements

  • Compiler that supports C++17 standard. Both clang++ and g++ seem to work.
  • CLI11 for option parsing.
  • PoDoFo for PDF export.
  • Courier Prime to work around PoDoFo 0.10.x font issues.

Building

This project uses meson build scripts with a make wrapper for convenience.

git clone https://github.com/xiota/ftn2xml.git
cd ftn2xml
make

Installing

The makefile contains an install target.

make install

To uninstall, delete the files and folders listed in build/meson-logs/install-log.txt.

License

This software is licensed under the GPL-3.0-or-later.

ftn2xml's People

Contributors

xiota avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

chariegg

ftn2xml's Issues

ftn2pdf outputs HTML

The command I ran

ftn2pdf sample.fountain sample.pdf

The sample script

Title:
    Show Title
    Cool Sub-Title
Credit: Written by
Author: Steven Jay Cohen
Contact:
    Steven Jay Cohen
    123 Main Street #24
    Boston, MA 02134
    781-555-1212
    [email protected]

INT. PHONE CALL - EVENING

# Scene 0: Cold Open

= Maggie is woken up by an automated phone call she does not want.

VOICE RECORDING
Hello, this is an important message from the Chase Visa Department of Collections. We are reaching out to -- Margaret Protagonist -- regarding your Chase Visa account ending in -- 3292.

Maggie sighs.

VOICE RECORDING
Our records indicate that there is an outstanding balance of $89,532 and 47 cents. We understand that financial situations can be challenging, and we're here to help you find a solution to bring your account back into good standing.

Maggie breathes.

VOICE RECORDING
If you would like to hear this information again, please press 1 now. To discuss the available options for resolving this matter with a representative, press 2 now.

Maggie presses 2

VOICE RECORDING
Thank you. Our customer service team is ready to assist you in finding a suitable solution. Please hold for the next available representative.

Hold Music

VOICE RECORDING
Thank you for your patience. A representative will be with you shortly to assist you in setting up a payment plan or discussing other options to help you get back on track with your account.

Hold Music

VOICE RECORDING
We value your business and are committed to helping you find a resolution. We appreciate your attention to this matter and look forward to working with you. Please continue to hold for the next available representative.

Hold Music

CUSTOMER SERVICE
Thank you for choosing Amazon-Chase Visa, my name is Elaine, to whom do I have the pleasure of–?

Maggie disconnects the call, breathes calmly and slowly, and puts down the phone.

> FADE TO OPENING.

INT. THE OFFICE

# SCENE 1

= Everyone still hungover from the office party.

GEORGE
You've got some nerve, showing your face around here today.

MAGGIE
(headache and sarcasm)
Good morning to you too, George.

When trying to open the resulting file, I get this error

image

Here is the file

sample.pdf

Changing the filetype to .html does give proper HTML

  • Debian 12 (stable)
  • PoDoFo v0.9.8+dfsg-3+b1 installed from the Debian Stable repo

Output PDF document does not display scene numbering. Even if it's in the fountain file.

I find your command line program to be very cool. However, it lacks in one thing: scene numbering. What it does is if the numbering like 'poundsign-number-poundsign' is in the right place, just bold the scene or if improperly (like at the start because I made a mistake with where to put it), it removes the scene line (such as INT. or EXT.) entirely. I'm going to provide my example fountain file and the output to what ftn2pdf generated. I'll even share with you a short awk/perl snippet I used to number all the scenes, though I haven't tried it yet when a scene is already numbered.

awk '/^INT.|^EXT./ {$0=$0 " #NUMBERLATER#"} 1' $1 > $2
perl -pe 's/NUMBERLATER/++$i/e' $RNAME > $OUTPUTNAME

If you could please add an option to number scenes upon conversion and correctly show the scene numbering if they're put in the document properly, that would be great to have. Thank you for this project.

example.file.txt
output.pdf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.