Skip to content

Commit

Permalink
Fountain preview support 🌼
Browse files Browse the repository at this point in the history
- 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
fairybow committed Feb 2, 2023
1 parent 412649c commit 830ffcf
Show file tree
Hide file tree
Showing 20 changed files with 558 additions and 25 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Fernanda's look was inspired by the nice and quiet feeling of using [WordStar](h

Fernanda got its name because I just really like the name a lot. But, as it turns out, Fernanda means an ["adventurous, bold journey"](https://en.wikipedia.org/wiki/Fernanda) (the kind one might be *called* to, say), and I think that's neat. <img src="./fernanda/res/icons/fernanda.ico" alt="Colorful conch shell icon." width="16px"/>

[&#9166;](#top)
[:leftwards_arrow_with_hook:](#top)

## :honeybee: **Build** <a name="build"></a>

Expand Down Expand Up @@ -79,11 +79,14 @@ Among the other fonts used are:

Solarized theme palettes by [@altercation](https://github.com/altercation/solarized)

Markdown preview support provided with:
[Markdown](https://www.markdownguide.org/)/[Fountain](https://fountain.io/) preview support provided with:
- [Marked.js](https://github.com/markedjs/marked)
- and [Markdown.css](https://bitbucket.org/kevinburke/markdowncss)
- [Markdown.css](https://bitbucket.org/kevinburke/markdowncss)
- and [Fountain.js](https://github.com/mattdaly/Fountain.js)

[&#9166;](#top)
> **Note:** Markdown/Fountain support is, at the moment, extremely barebones!
[:leftwards_arrow_with_hook:](#top)

## :star: **Features** <a name="features"></a>

Expand All @@ -95,7 +98,7 @@ Markdown preview support provided with:
- Save backups (in [`{userdata}\backup\.rollback`](#folders))
- Global line, word, and character totals
- Export to PDF or directory
- Markdown preview
- Markdown/Fountain preview

---

Expand Down Expand Up @@ -153,7 +156,7 @@ If you want to manually rename, move, or delete items within a `.story` file via
</kbd>
</p>

[&#9166;](#top)
[:leftwards_arrow_with_hook:](#top)

## :floppy_disk: **Installation** <a name="install"></a>

Expand All @@ -179,7 +182,7 @@ You can grab the installer on the [Releases](https://github.com/fairybow/fernand

They can be opened via the `Help` menu.

[&#9166;](#top)
[:leftwards_arrow_with_hook:](#top)

## :compass: **Roadmap** <a name="roadmap"></a>

Expand All @@ -194,19 +197,19 @@ If I think of something big, I'll try to add it right here. Otherwise, these thi
- Persist undo/redo stacks between file changes
- Separators and possibly customizable file icons, for better mental organization at-a-glance
- Simple storage of links and research materials
- Fountain preview/export support
- Markdown/Fountain export

More to come.

[&#9166;](#top)
[:leftwards_arrow_with_hook:](#top)

## :smiley_cat: **Thanks** <a name="thanks"></a>

A major thanks to [@philipplenk](https://codemetas.de/) for their teaching and interest and support in helping me work toward a small dream like this (and for helping me make Fernanda available for [Arch Linux](https://aur.archlinux.org/packages/fernanda)).

A major thanks, too, to [@rikyoz](https://github.com/rikyoz/) for their tireless work on the very amazing [Bit7z library](https://github.com/rikyoz/bit7z).

[&#9166;](#top)
[:leftwards_arrow_with_hook:](#top)

## :hibiscus: **Screens** <a name="screens"></a>

Expand Down Expand Up @@ -275,8 +278,8 @@ A major thanks, too, to [@rikyoz](https://github.com/rikyoz/) for their tireless
</tbody>
</table>

[&#9166;](#top)
[:leftwards_arrow_with_hook:](#top)

## :heartpulse: **Bye** <a name="bye"></a>

[&#9166;](#top)
[:leftwards_arrow_with_hook:](#top)
2 changes: 2 additions & 0 deletions fernanda/docs/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- text.h (+ version.h)
- preview.h
- layout.h
- userdata.h (+ path.h)
- resource.h
- path.h
- splitter.h
Expand Down Expand Up @@ -280,6 +281,7 @@
### preview.h
```
#include "layout.h"
#include "userdata.h"
#include <QDesktopServices>
#include <QEvent>
Expand Down
21 changes: 21 additions & 0 deletions fernanda/docs/fountain.js/LICENSE.md
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.
110 changes: 110 additions & 0 deletions fernanda/docs/fountain.js/readme.md
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.
1 change: 1 addition & 0 deletions fernanda/docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
- [x] ~~May not need `makePosix()`; Bit7z only accepts `\\` paths for searching~~

### Resource
- [ ] DataPair should be split up. A lot of instances' lhs-es aren't even paths.
- [x] ~~There surely must be a smarter way to incorporate `.otf` into the fonts RC list (applies to MainWindow, too)~~
- [x] ~~Convert to `std::filesystem::path`~~

Expand Down
Binary file added fernanda/docs/zips/Fountain.js.zip
Binary file not shown.
3 changes: 2 additions & 1 deletion fernanda/fernanda.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
<None Include="..\README.md" />
<None Include="cpp.hint" />
<None Include="docs\palette.md" />
<None Include="res\preview\index.html" />
<None Include="res\preview\fountain.html" />
<None Include="res\preview\markdown.html" />
<None Include="res\sample\Sample.fernanda_editor" />
<None Include="res\sample\Sample.fernanda_window" />
<None Include="res\themes\bar\green.qss" />
Expand Down
9 changes: 6 additions & 3 deletions fernanda/fernanda.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,15 @@
<None Include="util\win_pack.bat">
<Filter>Utilities</Filter>
</None>
<None Include="res\preview\index.html">
<Filter>Resource Files\Preview</Filter>
</None>
<None Include="util\win_installer.nsi">
<Filter>Utilities</Filter>
</None>
<None Include="res\preview\markdown.html">
<Filter>Resource Files\Preview</Filter>
</None>
<None Include="res\preview\fountain.html">
<Filter>Resource Files\Preview</Filter>
</None>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
Expand Down
5 changes: 4 additions & 1 deletion fernanda/res/preview.qrc
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>
27 changes: 27 additions & 0 deletions fernanda/res/preview/fountain.html
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>
Loading

0 comments on commit 830ffcf

Please sign in to comment.