EXTINCTION-LEVEL ENTERTAINMENT

This site and the extinction-level.com and extinction-level.uk domains are really just E.L.E.'s web parking spot. In the meantime, it's a convenient place to sandbox some stuff I am working on, and a fast server to muck with.

Some of my clients:
elenameg.com | fracktherules.com | fucktherules.uk | talkingtothemoon.uk | extinction-level.uk | cadenza.ca

Because there's movie development going on that needs some mobile writing and brainstorming between the principals, I'm hacking together a bit of script that converts fountain markup into Final Draft XML.

Why Fountain markup?

According to fountain.io Fountain allows you to write screenplays in any text editor on any device. Because it's just text, it's portable and future-proof.

Fountain Syntax

I am only covering the syntax and elements I personally need for keeping our writers happy, mobile, and Final Draft compatible. This is not the entire Fountain markup codex (which is gorgeously small), just what we need now. It will probably suit your needs too, which is why I am making it available.

About Final Draft, although it is an industry standard software package, I am referring to the file format generated by Final Draft 11, and readable by just about every screenwriting application out there. The basic Final Draft file (with an fdx extension) is XML. The nuts and bolts of the fdx XML file are the same (element names, etc.) across all platforms. The fdx file is readable in any plain text editor which makes it easy to modify without a workstation or non mobile device. Also various platforms add their own bloat and junk code to the fdx XML file (especially Final Draft, itself).

Fortunately, all one needs to concern his/her/their self with, when writing on the run, or a tropical beach, in Fountain Markup and grafting into an fdx file, is contained in the first <content> element. My mission is to provide a JavaScript to convert Fountain Markup into the XML elements that can be simply spliced into that content element in a final draft file.

For now, here's an explanation of Fountain Markup and what it looks like in Final Draft XML.

Scene Heading

Fountain Markup


INT. HOUSE - DAY

.out of body OPERATING THEATRE - DAY

Final Draft XML

    <Paragraph Type="Scene Heading">
      <Text>INT. HOUSE - DAY</Text>
    </Paragraph>

    <Paragraph Type="Scene Heading">
      <Text>out of body OPERATING THEATRE - DAY</Text>
    </Paragraph>

Fountain to Final Draft REGEXP

Selects any line starting with a dot OR Preceded by a newline, containing INT EST EXT I/E AND followed by a blank line.


SEARCH    ^\.((?:(?!\.{2,3}).*))|((?<=\n)((EXT.*)|(INT.*)|(EST.*)|(I\/E.*))(?=\n\n))  Flags: gm

REPLACE [    <Paragraph Type="Scene Heading">\n      <Text>$2$1</Text>\n    </Paragraph>] Include whitespace BUT do NOT include [brackets]

Action

Fountain Markup


INT. HOUSE - DAY

This is another paragraph of action following the preceding 
paragraph. Then some more action.

And this is more action following a blank line. But if you just use a hard
return it will not divide lines.

Final Draft XML

    <Paragraph Type="Action">
        <Text>This is another paragraph of action following the preceding paragraph.
        Then some more action.</Text>
    </Paragraph>
    <Paragraph Type="Action">
        <Text>And this is more action following a blank line. But if you just use 
        a hard return it will not divide lines.</Text>
    </Paragraph>

Fountain to Final Draft REGEXP

Selects any line starting with an exclamation point OR beginning with a blank line AND ending with punctuation followed by a blank line.


SEARCH   ^\!(.*)\n|(?<=\n\n)(.*[,\.:;\?\!\>\<"'])\n$  Flags: gm 

REPLACE [    <Paragraph Type="Action">\n      <Text>$2$1</Text>\n    </Paragraph>] Include whitespace BUT do NOT include [brackets]

Character

Fountain Markup


HONCHO
- - - - - - or 

@McHONCHO del TORO

Final Draft XML

    <Paragraph Type="Character">
      <Text>HONCHO</Text>
    </Paragraph>
    
    <Paragraph Type="Character">
      <Text>McHONCHO del TORO</Text>
    </Paragraph>

Fountain to Final Draft REGEXP

Selects lines in ALLCAPS preceded by a blank line and followed by a non-blank line OR starting with an @ symbol.


SEARCH   ^\@(.*)\n|(?<=\n\n)([A-Z\s^\n]*)\n  Flags: gm  

REPLACE [    <Paragraph Type="Character">\n      <Text>$2$1</Text>\n    </Paragraph>] Include whitespace BUT do NOT include [brackets]

Dialogue

Fountain Markup


HONCHO
What are you telling me?

HONCHETTE
(lighting up a stogie)
It's like this, see...
I just hit a hard return after those three dots. And it will start text on the
next
line.

Final Draft XML

    <Paragraph Type="Character">
      <Text>HONCHO</Text>
    </Paragraph>
    <Paragraph Type="Dialogue">
      <Text>What are you telling me?</Text>
    </Paragraph>
    <Paragraph Type="Character">
      <Text>HONCHETTE</Text>
    </Paragraph>
    <Paragraph Type="Parenthetical">
      <Text>(lighting up a stogie)</Text>
    </Paragraph>
    <Paragraph Type="Dialogue">
      <Text>It's like this, see...</Text>
    </Paragraph>
    <Paragraph Type="Dialogue">
      <Text>I just hit a hard return after those three dots. And it will start text on the</Text>
    </Paragraph>
    <Paragraph Type="Dialogue">
      <Text>next</Text>
    </Paragraph>
    <Paragraph Type="Dialogue">
      <Text>line.</Text>
    </Paragraph>

Fountain to Final Draft REGEXP


Parenthetical

Fountain Markup


HONCHETTE
(lighting up a stogie)
It's like this, see...
(gasping)
This isn't a cigar!

Final Draft XML

    <Paragraph Type="Character">
      <Text>HONCHETTE</Text>
    </Paragraph>
    <Paragraph Type="Parenthetical">
      <Text>(lighting up a stogie)</Text>
    </Paragraph>
    <Paragraph Type="Dialogue">
      <Text>It's like this, see...</Text>
    </Paragraph>
    <Paragraph Type="Parenthetical">
      <Text>(gasping)</Text>
    </Paragraph>
    <Paragraph Type="Dialogue">
      <Text>This isn't a cigar!</Text>
    </Paragraph>

Fountain to Final Draft REGEXP


Transition

Fountain Markup


CUT TO:

> Desprocket and melt.

Final Draft XML

    <Paragraph Type="Transition">
      <Text>CUT TO:</Text>
    </Paragraph>

    <Paragraph Type="Transition">
      <Text>Desprocket and melt.</Text>
    </Paragraph>

Fountain to Final Draft REGEXP


Emphasis

Fountain Markup

This is action, but it doesn't have to be. I could be applying 
standard markdown to dialogue, parenthetical or whatever. First 
off, this *will be rendered in italics.* This will **be bold** and
this will ***be bold italics*** for something _important, underline_ it.

Final Draft XML


    <Paragraph Type="Action">
      <Text>This is action, but it doesn't have to be. I could be 
      applying standard markdown to dialogue, parenthetical or 
      whatever. First off, this </Text>
      <Text Style="Italic">will be rendered in italics.</Text>
      <Text> This will </Text>
      <Text Style="Bold">be bold</Text>
      <Text> and this will </Text>
      <Text Style="Bold+Italic">be bold italics</Text>
      <Text> for something </Text>
      <Text Style="Underline">important, underline</Text>
      <Text> it.</Text>
    </Paragraph>

Fountain to Final Draft REGEXP


Boneyard Comments

Fountain Markup


INT. HOUSE - DAY

This is another paragraph of action following the preceding 
paragraph. Then some more action. /* This is a comment */

And this is more action following a blank line. But if you just use a hard
return it will not divide lines.

/* this is another comment
it will be ignored and is only for notes in the
fountain markup */

Final Draft XML

    <Paragraph Type="Action">
        <Text>This is another paragraph of action following the preceding paragraph.
        Then some more action.</Text>
    </Paragraph>
    <Paragraph Type="Action">
        <Text>And this is more action following a blank line. But if you just use 
        a hard return it will not divide lines.</Text>
    </Paragraph>

Fountain to Final Draft REGEXP


SEARCH (\/\*)(.|\r|\n)*?(\*\/) flags: g

REPLACE "" with absolutely nothing.

Dual Dialogue

Centered Text

Sections and Synopses

Title Page

Page Breaks

Notes


DIY Online Final Draft File Viewer

Turning a Final-Draft(trademark) Screenplay into real HTML

The Proper Way

I've done the heavy lifting for you.

First off: Final Draft (11, at least) squeezes out straight up XML! Yup, like a stone age word processor. Course, FD screws it up so ye olde free office prog won't open it.

Open it in a text editor. I use Bluefish Use what you like: kate; vi; emacs; notepad++; just as long as it's got a decent pcre (that's search and replace with regular expressions) interface.

Hint: the only code you're interested in is between the first <Content> and </Content> tags (the Content element and its children).

FOLLOW THESE INSTRUCTIONS

Here's my REGEXP set (Javascript style). Know what to do with it, brilliant! Not a geek? I've coded a wee J-script you can run on your your own *.fdx file down below.

replace(/(?<=\<\/Content\>)[\s\S]*/m, ""); // DELETE everything past the first /Content tag
replace(/[\s\S]*(?=\<Content\>)/m, "");    // DELETE everything before the first Content tag
replace(/\<SceneProperties[\s\S]*?\/SceneProperties\>/gm, ""); // DELETE SceneProperties tags and contents
replace(/\<ScriptNote[\s\S]*\/ScriptNote\>/g,"");              // DELETE embedded ScriptNotes
replace(/\<Picture.*\/\>/g,"");                                // DELETE embedded Pictures
replace(/(\<Paragraph\x20)(.+)(Type)/g, "$1$3"); // DELETE properties preceding Type in Paragraph tags 
replace(/(Style.*[^\>]AllCaps[^\>]*\>)(.*)(\<\/Text\>)/g, '$1<span class="ACaps">$2</span>$3'); // ADD CSS for AllCaps
replace(/(Style.*[^\>]Underline[^\>]*\>)(.*)(\<\/Text\>)/g, "$1<u>$2</u>$3");        // ADD HTML for Underline
replace(/(Style.*[^\>]Italic[^\>]*\>)(.*)(\<\/Text\>)/g, "$1<em>$2</em>$3"); 	       // ADD HTML for Italic
replace(/(Style.*[^\>]Bold[^\>]*\>)(.*)(\<\/Text\>)/g, "$1<strong>$2</strong>$3");   // ADD HTML for Bold
replace(/(\<Text[^\>]*\>)(.*)(\<\/Text\>)\n\x20*/g, "$2"); // DELETE Text tags+properties, TIDY white space 
replace(/\"Scene Heading\"/g, '"Scene-Heading"'); // REPLACE "Scene Heading" WITH "Scene-Heading"
replace(/\"Cast List\"/g, '"Cast-List"');         // REPLACE "Cast List" WITH "Cast-List"
replace(/\"New Act\"/g, '"New-Act"');             // REPLACE "New Act" WITH "New-Act"
replace(/\"End of Act\"/g, '"End-of-Act"');       // REPLACE "End of Act" WITH  "End-of-Act"
replace(/\<Content\>/g, '<article class="screenplay">');  // REPLACE "<Content>" WITH '<article class="screenplay">'
replace(/\<\/Content\>/g, "</article>");   // REPLACE "</Content>" WITH "</article>"
replace(/\<Paragraph\sType=/g, '<p class=');//REPLACE "<Paragraph Type=" WITH  '<p class="'
replace(/\<\/Paragraph\>/g, "</p>");       // REPLACE "</Paragraph>" WITH "</p>"

I'm using Final Draft's <ElementSettings> properties to define the CSS (minus unneeded stuff to get the play online). After my wee J-script turns your fdx content into html and shoves it onscreen as a HTML5 article element, you need to copy that article element and all its inner HTML to a webpage (This is Javascript - the ONLY file access it can do is READING, not writing.

Here's the CSS code you need. (Tweak it how it looks right for you). Copy and paste it into your <head> element.

<style type="text/css">
  /* FINAL DRAFT FORMAT SHORTCUTS */
  article.screenplay {
    margin: 0 auto;
    font-family: "Courier New", Courier, monospace;
    font-size: 1em;
    width: 38em;
    padding-top: 3em;
    
    padding-bottom: 2em;
  }
  p.General {margin: 0;}
  p.Scene-Heading {margin-top: 2em; margin-bottom: 0; text-transform: uppercase;}
  p.Action {margin-top: 1em; margin-bottom: 0;}
  p.Character {margin-left: 12em; margin-top: 1em; margin-bottom: 0; text-transform: uppercase;}
  p.Parenthetical {margin-left: 8em; margin-right: 16em; margin-top: 0; margin-bottom: 0;}
  p.Dialogue {margin-left: 6em; margin-right: 9em; margin-top: 0; margin-bottom: 0;}
  p.Transition {text-align: right; margin-right: 5em; margin-top: 1em; margin-bottom: 0; text-transform: uppercase;}
  p.Shot {margin-top: 2em; margin-bottom: 0; text-transform: uppercase;}
  p.Cast-List {margin: 0; text-transform: uppercase;}
  p.New-Act {margin-top: 1em; margin-bottom: 0; text-transform: uppercase; text-decoration: underline; font-weight: bold;}
  p.End-of-Act {margin-top: 2em; margin-bottom: 0; text-transform: uppercase; text-decoration: underline; font-weight: bold;}
</style>

Now for the magic. See your Final Daft play with a few clicks.

DISCLAIMER: I've coded no form-validation or finger-poking debugging into this sandbox. You can probably load whatever you want into the script. You might crash your browser. Your script might look like dog vomit. I don't know, but your file (or whatever you load) is unchanged. This is just a viewer.


Select the *.fdx file you want to turn into HTML and or view. You can load just about anything, but don't, or you'll be sorry!


 

The following code can seem really LONG. Here's a link to the start of the file formatted for the browser: The viewer.

 

 

Here is where you will see the content of your screenplay as an article element. You can copy and paste this into your webpage if you want, or just behold the beauty of code.

Back to the beginning of the code suitable for copying and pasting

Below, is your play formatted for the browser. In other words, this is the viewer.

Back to the clicky file load button and top of the code.