-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adjusted Readme - Added Set menu option for Preview Type (Fountain or Markdown) - Added Fountain support to Preview - Added Fountain.js assets to support the above
- Loading branch information
Showing
20 changed files
with
558 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Matt Daly | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
fountain-js | ||
=========== | ||
|
||
fountain-js is a JavaScript based parser for the screenplay format [Fountain](http://fountain.io/). | ||
|
||
You can [try fountain-js out](http://mattdaly.github.com/Fountain.js/). The file system currently uses the HTML 5 File API, which means not all browsers support it, you'll be told if yours doesn't - I'm working on compatiblity. CSS styling isn't complete, so some elements aren't placed correctly and the text spacing might not be quite right, and, as you'll see, individual pages aren't currently supported either. | ||
|
||
# Syntax Support | ||
|
||
As of version 0.1.8 the full Fountain syntax is supported. | ||
|
||
Currently fountain-js supports a limited range of key-value pairs for title pages - | ||
|
||
* Title, Credit, Author/s, Source, Notes, Draft date, Date, Contact, Copyright | ||
|
||
Work is being done to make title page parsing friendlier, allowing custom key-value pairs, but as of version 0.1.0 only the above are supported. | ||
|
||
Instructions | ||
============ | ||
|
||
fountain-js accepts a string value to it's parse function, therefore opening or retrieving files is down to you - open the file, retrieve it's string contents and pass it to fountain-js. | ||
|
||
The parser doesn't simply change scripts lines in to html, it first splits the script down line by line and generates an array of tokens representing each script element. This tokenized array provides the opportunity to iterate over a script in it's raw state and do some analysis (e.g. we could search for every character element with the name STEEL, we could do this against the HTML using jQuery but it'd be a slower process). By default, fountain-js simply returns the generated html, but you can also gain access to those tokens if you ask for them (more on that below). | ||
|
||
To use Fountain.js, either import it within an HTML page or require it as a module inside Node.js (it's available to both by default). | ||
|
||
``` | ||
<script type="text/javascript" src="fountain.js"></script> | ||
<script type="text/javascript"> | ||
var file = ... open the file from somewhere and get it's string value ... | ||
var output = fountain.parse(file); | ||
</script> | ||
``` | ||
|
||
fountain-js supports both sync and async functionality, the function names remain the same. For async, simply attach a callback to the parse function and handle the result inside that callback. | ||
|
||
``` | ||
<script type="text/javascript" src="fountain.js"></script> | ||
<script type="text/javascript"> | ||
var file = ... open the file from somewhere and get it's string value ... | ||
fountain.parse(file, function (output) { | ||
// do something | ||
}); | ||
</script> | ||
``` | ||
|
||
The output provided by fountain-js is of a specific format. The output to both sync and async functions is an object literal of the format { title: '...', html: { title_page: '...', script: '...' } }. If a title was set in the original file the title property will be set to it (as plain text with formatting removed), the html.title_page property contains the html generated for any title page syntax definitions, and the html.script property contains the html generated for the rest of the script. | ||
|
||
``` | ||
<script type="text/javascript" src="fountain.js"></script> | ||
<script type="text/javascript"> | ||
var file = ... open the file from somewhere and get it's string value ... | ||
fountain.parse(file, function (output) { | ||
// output.title - 'Big Fish' | ||
// output.html.title_page - '<h1>Big Fish</h1><p class="author">...' | ||
// output.html.script - '<h2><span class="bold">FADE IN:</span></h2>...' | ||
}); | ||
</script> | ||
``` | ||
|
||
If you want access to the tokens that fountain-js generates, simply attach a true parameter to your parse calls. Requesting tokens adds a tokens property to the output generated by fountain-js. That tokens property is an array of object literals, each of the form { type: '...', text: '...' }, some elements have additional properties (e.g. the type 'scene_heading' also has a property called 'scene-number' if a scene number was attached to that specific scene heading). It should also be noted that fountain-js iterates the script from bottom to top, therefore requesting tokens requires reversing the array before fountain-js returns you the data, this might add a slight delay (milliseconds in most cases) on large scripts. | ||
|
||
``` | ||
<script type="text/javascript" src="fountain.js"></script> | ||
<script type="text/javascript"> | ||
var file = ... open the file from somewhere and get it's string value ... | ||
fountain.parse(file, true, function (output) { | ||
// output.title - 'Big Fish' | ||
// output.html.title_page - '<h1>Big Fish</h1><p class="author">...' | ||
// output.html.script - '<h2><span class="bold">FADE IN:</span></h2>...' | ||
// output.tokens - [ ... { type: 'transition'. text: '<span class="bold">FADE IN:</span>' } ... ] | ||
}); | ||
</script> | ||
``` | ||
|
||
The tokens for the Brick & Steel sample found on the fountain.io website would look as follows (just a small sample): | ||
|
||
``` | ||
[ | ||
..., | ||
{ type="scene_heading", text="EXT. BRICK'S PATIO - DAY", scene_number="1"}, | ||
{ type="action", text="A gorgeous day. The su...emplating -- something."}, | ||
{ type="action", text="The SCREEN DOOR slides ...es with two cold beers."}, | ||
{ type="dialogue_begin"}, | ||
{ type="character", text="STEEL"}, | ||
{ type="dialogue", text="Beer's ready!"}, | ||
{ type="dialogue_end"}, | ||
{ type="dialogue_begin"}, | ||
{ type="character", text="BRICK"}, | ||
{ type="dialogue", text="Are they cold?"}, | ||
{ type="dialogue_end"}, | ||
{ type="page_break"}, | ||
{ type="dialogue_begin"}, | ||
{ type="character", text="STEEL"}, | ||
{ type="dialogue", text="Does a bear crap in the woods?"}, | ||
{ type="dialogue_end"}, | ||
{ type="action", text="Steel sits. They laugh at the dumb joke."}, | ||
{ type="dialogue_begin"}, | ||
{ type="character", text="STEEL"}, | ||
{ type="parenthetical", text="(beer raised)"}, | ||
{ type="dialogue", text="To retirement."}, | ||
{ type="dialogue_end"}, | ||
{ type="dialogue_begin"}, | ||
{ type="character", text="BRICK"}, | ||
{ type="dialogue", text="To retirement."}, | ||
{ type="dialogue_end"} | ||
... | ||
``` | ||
|
||
As you can see fountain-js attaches some extra tokens, such as 'dialogue_begin' and 'dialogue_end'. These are used to block together sections, in the case of dialogue it allows fountain-js to attach a dual dialogue property to blocks of dialogue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>preview/index.html</file> | ||
<file>preview/include/fountain.min.js</file> | ||
<file>preview/include/fountain-js.css</file> | ||
<file>preview/include/markdown.css</file> | ||
<file>preview/include/marked.min.js</file> | ||
<file>preview/fountain.html</file> | ||
<file>preview/markdown.html</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<html lang="en"> | ||
<head> | ||
<link rel="stylesheet" href="include/fountain-js.css"> | ||
<script src="include/fountain.min.js"></script> | ||
<script src="qrc:/qtwebchannel/qwebchannel.js"></script> | ||
</head> | ||
<body> | ||
<div id="placeholder"></div> | ||
<script> | ||
'use strict'; | ||
var placeholder = document.getElementById('placeholder'); | ||
var updateText = function (text) { | ||
var output = fountain.parse(text); | ||
placeholder.innerHTML = output.html.title_page + output.html.script; | ||
} | ||
new QWebChannel(qt.webChannelTransport, | ||
function(channel) { | ||
var content = channel.objects.content; | ||
updateText(content.text); | ||
content.textChanged.connect(updateText); | ||
} | ||
); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.