diff options
author | Saeger Ryman <getSaeger@gmail.com> | 2015-11-11 00:00:00 +0000 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2024-01-18 10:05:22 +0100 |
commit | 965ad05661952de9f61593928547c8c93a7e42a2 (patch) | |
tree | e04c0d0e22d86a74e5bfc75e5a9b48d438f7bd95 | |
download | fountainflow.vim-1.0.tar.gz |
Version 1.0: Initial upload1.0
-rw-r--r-- | README.md | 55 | ||||
-rw-r--r-- | doc/fountainflow.txt | 251 | ||||
-rw-r--r-- | flowfiles/screenplayFooter.html | 2 | ||||
-rw-r--r-- | flowfiles/screenplayHeader.html | 12 | ||||
-rw-r--r-- | flowfiles/screenplayStyle.css | 126 | ||||
-rw-r--r-- | flowfiles/screenplayTitlePage.html | 24 | ||||
-rw-r--r-- | flowfiles/temp.txt | 1 | ||||
-rw-r--r-- | libreoffice/fountain-template-NO-synopsis.odt | bin | 0 -> 12147 bytes | |||
-rw-r--r-- | libreoffice/fountain-template-NO-synopsis.ott | bin | 0 -> 12185 bytes | |||
-rw-r--r-- | libreoffice/fountain-template-w-synopsis.fountain | 88 | ||||
-rw-r--r-- | libreoffice/fountain-template-w-synopsis.odt | bin | 0 -> 12087 bytes | |||
-rw-r--r-- | libreoffice/fountain-template-w-synopsis.ott | bin | 0 -> 12102 bytes | |||
-rw-r--r-- | plugin/fountainflow.vim | 280 |
13 files changed, 839 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc9430f --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +Fountain Flow for Vim +===================== + +Installation +------------ + +Basic installation is typical. There is a plugin file, and a help file. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + doc/ + fountainflow.txt + plugin/ + fountainflow.vim +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Template information is on board the plugin, so it is possible to convert files +right away. However, for greater control, templates and a style sheet are +including in a folder called 'flowfiles'. + +This and another folder named 'libreoffice' can go anywhere. But you are +required to include the following line in your .vimrc (preference file) so +that the plugin knows where to access the 'flowfiles'. + + let g:flow_directory = '/full/path/to/flowfiles/' + +Don't forget that trailing slash! + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + flowfiles/ + screenplayFooter.html + screenplayHeader.html + screenplayStyle.css + screenplayTitlePage.html + + libreoffice/ + fountain-template-NO-synopsis.odt + fountain-template-NO-synopsis.ott + fountain-template-w-synopsis.fountain + fountain-template-w-synopsis.odt + fountain-template-w-synopsis.ott +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +There is a reason the 'libreoffice' folder contains normal files along with the +templates, and a dummy FOUNTAIN file. An explanation for this, and more +information on using the templates will be available at our blog: + + https://vimwriter.blogspot.com/ + +Support +------- + +If you find this plugin useful, please consider throwing us some support via our blog donation button! + +Look for a new Fountain syntax file, and our upcoming plugin, Ink Flow for Vim, a general aid for creative writers on Vim that includes a logical settings, a snapshot function, file splitting, text block movement, etc. + diff --git a/doc/fountainflow.txt b/doc/fountainflow.txt new file mode 100644 index 0000000..19a01d3 --- /dev/null +++ b/doc/fountainflow.txt @@ -0,0 +1,251 @@ +*fountainflow.txt* Fountain syntax converter Last change: 2015-11-11 + +Fountain Flow *fountainflow* +by Saeger Ryman <getSaeger@gmail.com> +For feedback and notes, please visit https://vimwriter.blogspot.com/ + +INTRODUCTION |fountainflow-introduction| +BASIC OPERATION |fountainflow-basic| +LIBREOFFICE |fountainflow-libreoffice| +INSTALLATION |fountainflow-installation| +COMMANDS |fountainflow-commands| +SETTINGS |fountainflow-settings| +SUPPORTED SYNTAX |fountainflow-supported-syntax| +RECOMMENDATIONS |fountainflow-recommendations| + +============================================================================== +INTRODUCTION *fountainflow-introduction* + +This script uses Regex and Vimscript to convert FOUNTAIN screenplay files into +HTML that can then be sent to LibreOffice Writer as a fully-formed screenplays, +without the need for any further editing or formatting, apart from invoking +page numbers. A few editable templates and a CSS file control the styles. + +All FOUNTAIN syntax is supported, although at the moment dual dialogue is +limited to one line per character. The title page, along with the header and +footer, are controlled with editable templates. + +Page numbering can be easily set up simply by loading an included template. For +special situations, instructions are posted on this plugin's website: + + https://vimwriter.blogspot.com/p/fountain-flow.html + +BASIC OPERATION *fountainflow-basic* + +* Command :Flow converts Fountain syntax file to HTML +* Press <enter> to send the HTML file to LibreOffice +* Run the PageNumber macro in LibreOffice +* Resave as an OpenDocument file, or convert to PDF + +LIBREOFFICE *fountainflow-libreoffice* + +There are some inconsistencies with the word processor's operation that I +obviously have no control over. When the converted HTML file is sent to +LibreOffice Writer via this script, it should appear to be a perfectly +formatted screenplay; however, opening the HTML file from LibreOffice seems to +break formatting. + +INSTALLATION *fountainflow-installation* + +The plugin consists of one file, fountainflow.vim. The only required +installation is dropping that file in your plugin folder. Everything else is +optional. + +The plugin comes with a folder named 'flow', which contains templates. This can +be placed anywhere, so long as its location is updated in the settings (see +|g:flow_directory|). However, the plugin file will still function without it, +using default code in place of the templates. + +COMMANDS *fountainflow-commands* + + *fountainflow-:FountainFlow* + *fountainflow-:FF* +:FountainFlow Convert file with FOUNTAIN extension to HTML. +:FF Alias command. + + *fountainflow-:LibreOffice* +:LibreOffice This simply invokes LibreOffice's command line; it will + unconditionally send any file to LibreOffice Writer. Upon + converting to HTML, this can be done simply by pressing + <enter>. See |fountainflow-mappings| + + *fountainflow-:FlowDirectory* +:FlowDirectory Opens the file structure where the templates are kept. Upon + converting to HTML, this can be done simply by pressing + <home>. See |fountainflow-mappings| + +MAPPINGS *fountainflow-mappings* + +A few shortcuts are available immediately after converting the FOUNTAIN file to +HTML, and only within the HTML file's buffer. + +<enter> Send the converted output to LibreOffice Writer. + +<home> Go to templates. Opens the directory where the templates are + kept. Especially useful if you run the conversion, then find + you need to tweak the title page or styles. + +<backspace> Return to the original file in the same tab. + +<tab> Open the original file in another tab. + +<space> Open the original file in split view. + +<delete> Return to the original file and delete the HTML. This enables + quick housecleaning, as the HTML file is largely intended + simply as a temporary file for transferring the information + to LibreOffice. + +<esc> Clear the mappings. Use this if you want to edit the HTML + file. + +SETTINGS *fountainflow-settings* + + *g:flow_extensions* +List of allowable Fountain file extensions. The conversion script will not run +unless this file type is present in the current buffer. The default value is +"txt, fountain, spmd". Separate the extensions with a space. Commas are OK. + + let g:flow_extensions = "txt, fountain, spmd" + + *g:flow_directory* +This is the directory the script must access for templates and formatting. It +doesn't matter where you put the folder, but you should supply the full path. +The current configuration is for a Linux file system. Please include all +slashes, including the trailing slash. + + let g:flow_directory = '~/.vim/plugin/flow/' + + *g:flow_style_method* +The method of applying the stylesheet to the HTML, either 'embed' or 'link'. +The default is to embed, meaning that the CSS will be appended directly into +the HTML file. This is the safest method. + + let g:flow_style_method = "embed" + + *g:flow_title_page* + *g:flow_header* + *g:flow_footer* + *g:flow_style_sheet* +The source files, templates and stylesheet. You shouldn't have to change these, +unless you want to experiment and leave the default files in place. + + let g:flow_title_page = "screenplayTitlePage.html" + let g:flow_header = "screenplayHeader.html" + let g:flow_footer = "screenplayFooter.html" + let g:flow_style_sheet = "screenplayStyle.css" + + *g:flow_dual_processing* +Processing dual dialogue (two characters speaking at once) is optional, because +(to be honest) our regex doesn't handle it very well. We expect to make some +improvements, but since this might not be used frequently in your scripts +anyway, you can optionally turn it off to avoid the extra lag in processing +time. The options are 'yes' and 'no'. + + let g:flow_dual_processing = "yes" + + *g:flow_line_style* + *g:flow_line_style_spaced* +The way CSS governs text within LibreOffice is tricky. Paragraphs honor +left/right margins, but vertical margins seem wholly dependent on the page or +section setting. It seems the only way to overrule this is to insert the CSS on +a line-by-line basis, so the following defines the margin of lines that should +not have a visible space between them, and lines that should have one. The +first style should not have to be changed, but you may need to adjust the +'spaced' line in accordance to the font you use. + + let g:flow_line_style = "margin-top: 0pt; margin-bottom: 0pt;" + let g:flow_line_style_spaced = "margin-top: 18pt; margin-bottom: 0pt;" + +SUPPORTED SYNTAX *fountainflow-supported-syntax* + +In short, all Fountain syntax is supported. More accurately, we think we've got +it all covered. There will likely be issues in this early version that need +fixing. + +DUAL DIALOGUE is supported, but mentioned first because it has the weakest +support. At the moment, only one line of dialogue per character, plus optional +parenthetical, is supported. The following will work: + + BOB + But you-- + + RAY ^ + (flushed) + Dammit, let me finish! + +INDENTATION is supported, somewhat. Tabs and blocks of spaces in multiples of +four will be converted into HTML entities in order to preserve indentation +where indicated in ACTION. The 'four' stipulation simply means that a line that +begins with one or two spaces will not be indented, while nine spaces will be +interpreted as eight. + +Other lesser syntax is supported, and tagged in the HTML output, but may not +yet be adequately defined by the default CSS. In particular, I have no idea +what the proper format is for LYRICS, but lyrics are tagged and honored as a +particular class which can be styled as you see fit. + +Forced syntax is supported. The following blocks of dialogue will work. + + DAN + But you-- + + @McGREGOR + (flushed) + Dammit, let people finish! + +TRANSITIONS end with 'TO:', or can be forced with a greater-than. SCENE +HEADINGS can be forced with a leading period. + + CUT TO: + + EXT. THE ESTATE - DAY + + >WIPE + + .INT. McGREGOR'S LAB - DAY + +BONEYARDS, NOTES, and SECTIONS are for the writer's use, and are all deleted by +default. We are experimenting with a collaboration mode, which sounds a bit +fancy, but just means leaving all that stuff in. It's 'not ready for +prime-time', yet. In particular, there are some issues with notes. Technically, +Fountain NOTES can be converted into HTML comments which are then read by +LibreOffice as nice little margin notes, but in practice it gets messy. + +PAGE BREAKS are turned into HTML tags which are, in fact, interpreted by +LibreOffice as real-life, honest-to-gosh page breaks. + +EMPHASIS and UNDERLINING is supported, and hopefully will perform OK. This is +an advanced type of markup, and requires us to essentially emulate Markdown. + +Complete information on Fountain syntax can be found at + http://fountain.io/syntax + +RECOMMENDATIONS *fountainflow-recommendations* + +Screenplays require a courier font, and we recommend Courier Prime, which was +designed to be compatible with Final Draft. If Courier Prime is not present, +the default styling falls back on Courier New. Edit the CSS file to reflect +your preference. + + http://www.fontsquirrel.com/fonts/courier-prime + +FOuntain syntax allows the use of Markdown-style headers for internal +(non-printing) organization, so VOoM is an excellent tool to use while writing +your screenplay. + + http://www.vim.org/scripts/script.php?script_id=2657 + +We are preparing two new files to further enhance the writing experience: a new +and improved Fountain syntax file, and a general writer's aid (Ink Flow) which +will include some helpful functions and settings. + +Fountain Flow is donationware, and we really appreciate any and all support. +Please consider hitting the donation button at your blog. There you will also +find notes and screenshots and stuff. + + https://vimwriter.blogspot.com/p/fountain-flow.html + + +vi: et sw=2 ts=2 + diff --git a/flowfiles/screenplayFooter.html b/flowfiles/screenplayFooter.html new file mode 100644 index 0000000..308b1d0 --- /dev/null +++ b/flowfiles/screenplayFooter.html @@ -0,0 +1,2 @@ +</body> +</html> diff --git a/flowfiles/screenplayHeader.html b/flowfiles/screenplayHeader.html new file mode 100644 index 0000000..11b94f2 --- /dev/null +++ b/flowfiles/screenplayHeader.html @@ -0,0 +1,12 @@ +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=utf-8"> +<title></title> +<style> +<!-- + +--> +</style> +</head> +<body lang="en-US" dir="ltr"> + diff --git a/flowfiles/screenplayStyle.css b/flowfiles/screenplayStyle.css new file mode 100644 index 0000000..a900cbd --- /dev/null +++ b/flowfiles/screenplayStyle.css @@ -0,0 +1,126 @@ +@page:first +{ + margin: 0.75in 1in 0.75in 1.5in; +} +@page +{ + margin: 0.75in 1in 0.75in 1.5in; +} +p +{ + margin-top: 0pt; + margin-bottom: 0pt; + padding-top: 0pt; + padding-bottom: 0pt; + background: transparent; + line-height: 13pt; +} +.normal +{ + margin-top: 13pt; + margin-bottom: 0pt; + padding-top: 0pt; + padding-bottom: 0pt; + background: transparent; + line-height: 13pt; +} +body +{ + width: 8.5in; + background: #fff; + font-family: 'Courier Prime', 'courier new'; + font-size: 12pt; +} +.SceneHeading +{ + margin-top: 13pt; + page-break-before: auto; + page-break-after: avoid; +} +.Action, .Synopsis +{ + margin-top: 13pt !important; + orphans: 3; + widows: 3; +} +.Transitional +{ + margin-top: 13pt; + margin-left: 4in; +} +.Character +{ + margin-left: 2in; + page-break-before: auto; + page-break-after: avoid; +} +.Parenthetical +{ + margin-left: 1.5in; + margin-right: 1.5in; + page-break-after: avoid; +} +.Dialogue +{ + margin-left: 1in; + margin-right: 1in; + orphans: 2; + widows: 2; + page-break-before: avoid; + page-break-after: auto; +} +.DualCharacter +{ + margin-left: 1in; + page-break-before: auto; + page-break-after: avoid; +} +.DualParenthetical +{ + margin-left: 0.6in; + margin-right: 0.6in; + page-break-after: avoid; +} +.DualDialogue +{ + margin-left: 0.125in; + margin-right: 0.125in; + orphans: 2; + widows: 2; + page-break-before: avoid; + page-break-after: auto; +} +#TitlePage +{ + margin-right: 1.5in; + margin-left: 1.5in; + text-align: center; + margin-top: 13pt; + margin-bottom: 0pt; +} +#TitlePageNotes +{ + margin-top: 13pt; +} +#Spacer1 +{ + margin-top: 0.5in; +} +#Spacer2 +{ + margin-top: 3in; +} +h1, h2, h3, h4, h5, h6 +{ + font-family: serif; +} +.Notes +{ + font-family: serif; + color: #777; +} +.Boneyard +{ + text-decoration: line-through; +} + diff --git a/flowfiles/screenplayTitlePage.html b/flowfiles/screenplayTitlePage.html new file mode 100644 index 0000000..5953862 --- /dev/null +++ b/flowfiles/screenplayTitlePage.html @@ -0,0 +1,24 @@ +<div id="TitlePage"> + <div id="Spacer1"> + <p> </p> + </div> + <p class="Title">%Title%</p> + <p class="Author">%Credit% %Author%</p> + <p class="Source">%Source%</p> + <div id="Spacer2"> + <p> </p> + </div> + <table id="TitlePageTable" width="100%" style="page-break-inside: avoid"> + <tr> + <td id="TableLeft" width="50%;" align="left" valign="bottom"> + <p style="margin-top: 18pt; margin-bottom: 0pt;">%Contact%</p> + </td> + <td id="TableRight" width="50%" align="right" valign="bottom"> + <p style="margin-top: 18pt; margin-bottom: 0pt;">%Draftdate%</p> + <p style="margin-top: 18pt; margin-bottom: 0pt;">%Notes%</p> + <p style="margin-top: 18pt; margin-bottom: 0pt;">%Copyright%</p> + </td> + </tr> + </table> +</div> + diff --git a/flowfiles/temp.txt b/flowfiles/temp.txt new file mode 100644 index 0000000..83d9b9a --- /dev/null +++ b/flowfiles/temp.txt @@ -0,0 +1 @@ +@page:first\r{\r\tmargin: 0.75in 1in 0.75in 1.5in;\r}\r@page\r{\r\tmargin: 0.75in 1in 0.75in 1.5in;\r}\rp\r{\r\tmargin-top: 0pt;\r\tmargin-bottom: 0pt;\r\tpadding-top: 0pt;\r\tpadding-bottom: 0pt;\r\tbackground: transparent;\r\tline-height: 13pt;\r}\r.normal\r{\r\tmargin-top: 13pt;\r\tmargin-bottom: 0pt;\r\tpadding-top: 0pt;\r\tpadding-bottom: 0pt;\r\tbackground: transparent;\r\tline-height: 13pt;\r}\rbody\r{\r\twidth: 8.5in;\r\tbackground: #fff;\r\tfont-family: 'Courier Prime', 'courier new';\r\tfont-size: 12pt;\r}\r.SceneHeading\r{\r\tmargin-top: 13pt;\r\tpage-break-before: auto;\r\tpage-break-after: avoid;\r}\r.Action, .Synopsis\r{\r\tmargin-top: 13pt !important;\r\torphans: 3;\r\twidows: 3;\r} \r.Transitional\r{\r\tmargin-top: 13pt;\r\tmargin-left: 4in;\r}\r.Character\r{\r\tmargin-left: 2in;\r\tpage-break-before: auto;\r\tpage-break-after: avoid;\r}\r.Parenthetical\r{\r\tmargin-left: 1.5in;\r\tmargin-right: 1.5in;\r\tpage-break-after: avoid;\r}\r.Dialogue\r{\r\tmargin-left: 1in;\r\tmargin-right: 1in;\r\torphans: 2;\r\twidows: 2;\r\tpage-break-before: avoid;\r\tpage-break-after: auto;\r}\r.DualCharacter\r{\r\tmargin-left: 1in;\r\tpage-break-before: auto;\r\tpage-break-after: avoid;\r}\r.DualParenthetical\r{\r\tmargin-left: 0.6in;\r\tmargin-right: 0.6in;\r\tpage-break-after: avoid;\r}\r.DualDialogue\r{\r\tmargin-left: 0.125in;\r\tmargin-right: 0.125in;\r\torphans: 2;\r\twidows: 2;\r\tpage-break-before: avoid;\r\tpage-break-after: auto;\r}\r#TitlePage\r{\r\tmargin-right: 1.5in;\r\tmargin-left: 1.5in;\r\ttext-align: center;\r\tmargin-top: 13pt;\r\tmargin-bottom: 0pt;\r}\r#TitlePageNotes\r{\r\tmargin-top: 13pt;\r}\r#Spacer1\r{\r\tmargin-top: 0.5in;\r}\r#Spacer2\r{\r\tmargin-top: 3in;\r}\rh1, h2, h3, h4, h5, h6\r{\r\tfont-family: serif;\r}\r.Notes\r{\r\tfont-family: serif;\r\tcolor: #777;\r}\r.Boneyard\r{\r\ttext-decoration: line-through;\r}\r \r diff --git a/libreoffice/fountain-template-NO-synopsis.odt b/libreoffice/fountain-template-NO-synopsis.odt Binary files differnew file mode 100644 index 0000000..069e420 --- /dev/null +++ b/libreoffice/fountain-template-NO-synopsis.odt diff --git a/libreoffice/fountain-template-NO-synopsis.ott b/libreoffice/fountain-template-NO-synopsis.ott Binary files differnew file mode 100644 index 0000000..6ed01a1 --- /dev/null +++ b/libreoffice/fountain-template-NO-synopsis.ott diff --git a/libreoffice/fountain-template-w-synopsis.fountain b/libreoffice/fountain-template-w-synopsis.fountain new file mode 100644 index 0000000..3a96943 --- /dev/null +++ b/libreoffice/fountain-template-w-synopsis.fountain @@ -0,0 +1,88 @@ +Title: Screenplay with synopsis template +Credit: Written by +Author: Saeger Ryman + += Template for a Fountain screenplay with a synopsis page. + +==== + +EXT. VALHALLA - ETERNAL DAY + +RYMAN +Fountain Flow provides the styles when the script is first processed. This template is strictly for setting the page numbers of your screenplay. + +The way the page numbering works is that the first few pages are defined in this way: + +Page style: First page --> Next style: Synopsis Page +Page style: Synopsis Page --> Next style: First Script Page +Page style: First Script Page --> Next style: HTML +Page style: HTML + +A header is added to the HTML pages alone, and the page number offset. The aim is for the page numbers to begin on the second page of the script. + +RYMAN (CONT'D) +As long as your document matches the number of pages at the head, applying the page numbers should be easy. Here's how. +(clears throat) +Go to Styles and Formatting -- press F11 -- and find an icon in the top right corner with a PARAGRAPH SYMBOL. Click on that and select LOAD STYLES. + +Check off all the boxes below, or at least PAGES and NUMBERING. Then click the FROM FILE button in the lower left corner of the LOAD STYLES dialogue, and select this file. + +RYMAN (CONT'D) +The result should be automatic page numbering, starting on the second page of your script. + +FILLER enters, as there's nothing left to say, and we want enough text to spill over to page two. + +FILLER +I've got a coffee pot for a heart. + +RYMAN +That's a strange anatomical note. You mean you have a hot heart? + +FILLER +I could draw the analogy out some more. I've got a pencil. + +RYMAN +No need to explain. I've got a rice steamer for a brain. + +FILLER +Hold on, I'll demonstrate. + +FILLER fills his mouth with coffee grounds, then pours hot water down his throat and gargles. Meanwhile, INGENUE floats down holding a small balloon. + +RYMAN +Very interesting. + +INGENUE +Excuse me. Am I in the right place? I've got a microwave oven for a butt. You wouldn't believe the things that pop out! + +RYMAN +What d'you got? + +INGENUE +Let's see... + +INGENUE reaches behind her, and we hear a click and the squeak of a door opening. She pulls out a little plate of steamed veggies. + +RYMAN +Perfect! + +RYMAN lifts his hair off his head, revealing a brain-sized lump of white rice where his brains should be. + +RYMAN (CONT'D) +Do you mind? + +INGENUE slides the vegetables in and uses a big spoon to stir them. RYMAN repositions his hair, as FILLER surprises them with two steaming hot cups of coffee. + +FILLER +We've reached the end of page two, so my work here is done. + +>_**THE END**_< + + + + + + + + + diff --git a/libreoffice/fountain-template-w-synopsis.odt b/libreoffice/fountain-template-w-synopsis.odt Binary files differnew file mode 100644 index 0000000..754fd45 --- /dev/null +++ b/libreoffice/fountain-template-w-synopsis.odt diff --git a/libreoffice/fountain-template-w-synopsis.ott b/libreoffice/fountain-template-w-synopsis.ott Binary files differnew file mode 100644 index 0000000..06ab393 --- /dev/null +++ b/libreoffice/fountain-template-w-synopsis.ott diff --git a/plugin/fountainflow.vim b/plugin/fountainflow.vim new file mode 100644 index 0000000..abf664a --- /dev/null +++ b/plugin/fountainflow.vim @@ -0,0 +1,280 @@ +" Utility: fountainflow.vim +" Author: Saeger Ryman, getSaeger@gmail.com +" Version: 1.0 +" Release Date: 2015-11-11 +" + +" Default VARIABLES {{{ +if !exists('g:flow_extensions') + let g:flow_extensions = 'txt fountain spmd' +endif +let g:flow_extensions = substitute(g:flow_extensions,",*\\s\\+","\\\\|","g") +if !exists('g:flow_directory') + let g:flow_directory = $HOME.'/.vim/plugin/flow/' +endif +if !exists('g:flow_style_sheet') + let g:flow_style_sheet = "screenplayStyle.css" +endif +if !exists('g:flow_style_method') + let g:flow_style_method = "embed" + " option: embed|link +endif +if !exists('g:flow_header') + let g:flow_header = "screenplayHeader.html" +endif +if !exists('g:flow_footer') + let g:flow_footer = "screenplayFooter.html" +endif +if !exists('g:flow_title_page') + let g:flow_title_page = "screenplayTitlePage.html" +endif +if !exists('g:flow_dual_processing') + let g:flow_dual_processing = "yes" + " option: yes/no +endif +if !exists('g:flow_collaboration') + let g:flow_collaboration = "no" + " option: yes/no +endif +if !exists('g:flow_line_style') + let g:flow_line_style = "margin-top: 0pt; margin-bottom: 0pt;" +endif +if !exists('g:flow_line_style_spaced') + :let g:flow_line_style_spaced = "margin-top: 13pt; margin-bottom: 0pt;" +endif +" }}} + +function! FountainTOhtml() + + " CREATE OR RETURN TO HTML FILE {{{ + echo "Loading HTML file." + let g:flow_original = expand("%") + let g:flow_html = expand("%:p:r").".temp.html" + if filereadable(g:flow_html) + silent exe 'normal ggvGg_"fy' + silent exe 'tab drop '.substitute(g:flow_html," ","\\\\ ","g") + exe 'normal ggvGg_"fp' + silent write + else + tab drop % + silent exe 'saveas! '.substitute(g:flow_html," ","\\\\ ","g") + endif + " }}} + + " Let's make sure we're in the right buffer! + if expand("%:p") == g:flow_html + echo "Everything looks OK." + if isdirectory(g:flow_directory) + echo "Template directory found." + else + echo "Template directory not found. Loading default code." + endif + + " Grab TITLE PAGE DATA {{{ + exe 'normal ggv' + exe '/^\s*$' + exe 'normal "fx' + let g:flow_data = substitute(@f,"\\n\\s\\+","<br>","g") + let fd = split(g:flow_data,"[\n]") + 0put='<p style=\"page-break-before: always;\"></p>' + " }}} + + " Remove or reformat SECTIONS/NOTES/BONEYARD {{{ + if g:flow_collaboration == "yes" + echo "Processing notes and other private data." + silent exe '%s/\v\[\[([^\]]*)\]\]/<p class="Notes" style="'.g:flow_line_style_spaced.'">\1<\/p>/ge' + else + echo "Removing notes and other private data." + silent %s/\v\[\[(.*)\]\]//ge + endif + if g:flow_collaboration == "yes" + silent %s/\v\/\*(\_.+)\*\//<span class="Boneyard">\1<\/span>/ge + else + silent %s/\v\/\*(\_.+)\*\///ge + endif + if g:flow_collaboration == "yes" + silent %s/\v^\s*#{6}\s(.+)$/<h6>\6<\/h6>/ge + silent %s/\v^\s*#{5}\s(.+)$/<h5>\5<\/h5>/ge + silent %s/\v^\s*#{4}\s(.+)$/<h4>\4<\/h4>/ge + silent %s/\v^\s*#{3}\s(.+)$/<h3>\3<\/h3>/ge + silent %s/\v^\s*#{2}\s(.+)$/<h2>\2<\/h2>/ge + silent %s/\v^\s*#{1}\s(.+)$/<h1>\1<\/h1>/ge + else + silent %s/\v^\s*#{1,6}\s.+\n+//ge + endif + " }}} + + " Insert PAGE BREAK {{{ + silent %s/\v^\s*\={3,}\s*/<p style="page-break-before: always;"><\/p>/ge + silent %s/\v^(\s*)\\(\={3,})\s/\1\2/ge + " }}} + + " Process SCENE HEADING and TRANSITIONAL {{{ + echo "Processing scene headers and transitions." + silent exe '%s/\v^$\n\c((\.|(int|ext|int\.\/ext|int\/ext|est|ie))(.+))\n^$/\r<p style="'.g:flow_line_style_spaced.'" class="SceneHeading">\3\4<\/p>\r/ge' + " + " Must process CENTERED before TRANSITIONAL + silent exe '%s/\v^\s*\>(.+)\</<p style="'.g:flow_line_style_spaced.' text-align: center;">\1<\/p>/ge' + + silent exe '%s/\v^$\n\s*(\>\s*(.+)|(\L+ TO:))\s*\n^$/\r<p style="'.g:flow_line_style_spaced.'" class="Transitional">\2\3<\/p>\r/ge' + " }}} + + " Process CHARACTER/PARENTHETICAL/DIALOGUE BLOCK {{{ + echo "Processing dialogue blocks." + silent exe '%s/\v^$\n\s*(\@([^\(]+)|([A-Z0-9]\L+))(\s*\(.+\))*\s*\n(.+)/\r<p style="'.g:flow_line_style_spaced.'" class="Character">\2\3\4<\/p>::c::\r\5/ge' + let lnum = 1 + while lnum <= (line("$"))-1 + silent exe lnum.','.lnum+1.'s/\v::[cd]::\n\s*(\(.+\))\n/\r<p style="'.g:flow_line_style.'" class="Parenthetical">\1<\/p>::p::\r/ge' + silent exe lnum.','.lnum+1.'s/\v::[cp]::\n(.+\n)/\r<p style="'.g:flow_line_style.'" class="Dialogue">\r\t\1<\/p>::d::\r/ge' + silent exe lnum.','.lnum+1.'s/\v::d::\n(.+\n)/\r<p style="'.g:flow_line_style_spaced.'" class="Dialogue">\r\t\1<\/p>::d::\r/ge' + let lnum = lnum + 1 + endwhile + silent %s/\v::.:://ge + " }}} + + " DUAL DIALOGUE {{{ + if g:flow_dual_processing == "yes" + echo "Processing dual dialogue." + %s/\v\n(\<p.*class\="Character"\_.{-})^$(\n.*class=\="Character".*)\^(\_.{-}\<\/p\>\n)^$/\r<table class="DualDialogue" width="100%">\r<tr>\r<td class="LeftDialogue" width="50%" valign="top">\r\1<\/td>\r<td class="RightDialogue" width="50%" valign="top">\2\3<\/td>\r<\/tr>\r<\/table>\r/ge + %s/\v((Left|Right)Dialogue\_.{-})class\="Character"(.*\n.*)class\="Parenthetical"(\_.{-})class\="Dialogue"/\1class="DualCharacter"\3class="DualParenthetical"\4class="DualDialogue"/ge + %s/\v((Left|Right)Dialogue\_.{-})class\="Character"(.*\n.*)class\="Dialogue"/\1class="DualCharacter"\3class="DualDialogue"/ge + else + echo "Dual dialogue processing switched off." + endif + " }}} + + " ETCETERA {{{ + echo "Etcetera, etcetera, etcetera." + + " Process SYNOPSIS + silent exe '%s/\v^\s*\=\s*([^\=].+)$/<div id="SynopsisPage">\r\r<p class="Synopsis" style="'.g:flow_line_style_spaced.'">\1<\/p>\r\r<\/div>/ge' + + " Process LYRICS + silent exe '%s/\v^\s*\~\s*(.*)/<p style="'.g:flow_line_style.'" class="Lyrics">\1<\/p>/ge' + + " PROTECTED LINES + silent exe '%s/\v^\\(.*)/<p style="'.g:flow_line_style_spaced.'">\1<\/p>/ge' + " }}} + + " Process ACTION {{{ + echo "Processing action." + silent exe '%s/\v^$\n(\s*)!?([^\<^\>].+)$/\r<p style="'.g:flow_line_style_spaced.'" class="Action">\1\2<\/p>:::/ge' + let lnum = 1 + while lnum <= (line("$"))-1 + silent exe lnum.','.lnum+1.'s/\v:::\n(\s*)!?([^\<^\>].+)$/\r<p style="'.g:flow_line_style.'" class="Action">\1\2<\/p>:::/ge' + :.s/\v\t/\ \ \ \ /ge + :.s/\v\s{4}/\ \ \ \ /ge + let lnum = lnum + 1 + endwhile + silent %s/\v::://ge + " }}} + + " Process EMPHASIS {{{ + echo "Processing emphasis." + silent %s/\v\\@<!_\s@!(.{-})(\s|\\)@<!_/<span style="text-decoration: underline;">\1<\/span>/ge + silent %s/\v\\_/_/ge + silent %s/\v\\@<!\*{3}\s@!(.{-})(\s|\\)@<!\*{3}/<span style="font-weight:bold; font-style:italic;">\1<\/span>/ge + silent %s/\v\\@<!\*{2}\s@!(.{-})(\s|\\)@<!\*{2}/<span style="font-weight:bold;">\1<\/span>/ge + silent %s/\v\\@<!\*{1}\s@!(.{-})(\s|\\)@<!\*{1}/<span style="font-style:italic;">\1<\/span>/ge + silent %s/\\\*/\*/ge + " }}} + + " FINISH PAGE {{{ + if filereadable(g:flow_directory.g:flow_title_page) + echo "Loading title page template." + silent exe '0read '.g:flow_directory.g:flow_title_page + else + echo "Inserting default title page template." + 1s/^/<div id="TitlePage">\r\t<div id="Spacer1">\r\t\t<p>\ <\/p>\r\t<\/div>\r\t<p class="Title">%Title%<\/p>\r\t<p class="Author">%Credit% %Author%<\/p>\r\t<p class="Source">%Source%<\/p>\r\t<div id="Spacer2">\r\t\t<p>\ <\/p>\r\t<\/div>\r\t<table id="TitlePageTable" width="100%" style="page-break-inside: avoid">\r\t\t<tr>\r\t\t\t<td id="TableLeft" width="50%;" align="left" valign="bottom">\r\t\t\t\t<p style="margin-top: 12pt; margin-bottom: 0pt;">%Contact%<\/p>\r\t\t\t<\/td>\r\t\t\t<td id="TableRight" width="50%" align="right" valign="bottom">\r\t\t\t\t<p style="margin-top: 12pt; margin-bottom: 0pt;">%Draftdate%<\/p>\r\t\t\t\t<p style="margin-top: 12pt; margin-bottom: 0pt;">%Notes%<\/p>\r\t\t\t\t<p style="margin-top: 12pt; margin-bottom: 0pt;">%Copyright%<\/p>\r\t\t\t<\/td>\r\t\t<\/tr>\r\t<\/table>\r<\/div>\r\r/ge + endif + " ADD DIV AROUND SCRIPT + silent exe 'normal G' + silent exe '?<\/div>' + silent exe '/page-break-before: always;' + silent exe 'normal o' + silent .s/^/\r\r<div id="ScriptPage"> + silent exe 'normal Go' + silent .s/^/\r\r<\/div> + " The above is kind of jury-rigged at the moment. + if filereadable(g:flow_directory.g:flow_header) + echo "Loading header template." + silent exe '0read '.g:flow_directory.g:flow_header + else + echo "Inserting default header template." + 1s/^/<html>\r<head>\r<meta http-equiv="content-type" content="text\/html; charset=utf-8">\r<title><\/title>\r<style>\r<!--\r\r-->\r<\/style>\r<\/head>\r<body lang="en-US" dir="ltr">\r\r/ge + endif + if filereadable(g:flow_directory.g:flow_footer) + echo "Loading footer template." + silent exe '$read '.g:flow_directory.g:flow_footer + else + echo "Inserting default footer template." + $s/$/\r<\/body>\r<\/html>/e + endif + if g:flow_style_method == 'embed' && filereadable(g:flow_directory.g:flow_style_sheet) + echo "Embedding styles." + exe 'normal gg' + exe '/\n\n\_.*\/style' + silent exe 'read '.g:flow_directory.g:flow_style_sheet + elseif g:flow_style_method == "link" + echo "Linking styles." + exe 'normal gg' + exe '/\n<\/head>' + put='<link rel=\"stylesheet\" type=\"text/css\" href=\"'.g:flow_directory.g:flow_style_sheet.'\">' + else + echo "Inserting default styles." + exe 'normal gg' + exe '/\n\n\_.*\/style' + .s/^/@page:first\r{\r\tmargin: 0.75in 1in 0.75in 1.5in;\r}\r@page\r{\r\tmargin: 0.75in 1in 0.75in 1.5in;\r}\rp\r{\r\tmargin-top: 0pt;\r\tmargin-bottom: 0pt;\r\tpadding-top: 0pt;\r\tpadding-bottom: 0pt;\r\tbackground: transparent;\r\tline-height: 13pt;\r}\r.normal\r{\r\tmargin-top: 13pt;\r\tmargin-bottom: 0pt;\r\tpadding-top: 0pt;\r\tpadding-bottom: 0pt;\r\tbackground: transparent;\r\tline-height: 13pt;\r}\rbody\r{\r\twidth: 8.5in;\r\tbackground: #fff;\r\tfont-family: 'Courier Prime', 'courier new';\r\tfont-size: 12pt;\r}\r.SceneHeading\r{\r\tmargin-top: 13pt;\r\tpage-break-before: auto;\r\tpage-break-after: avoid;\r}\r.Action, .Synopsis\r{\r\tmargin-top: 13pt !important;\r\torphans: 3;\r\twidows: 3;\r} \r.Transitional\r{\r\tmargin-top: 13pt;\r\tmargin-left: 4in;\r}\r.Character\r{\r\tmargin-left: 2in;\r\tpage-break-before: auto;\r\tpage-break-after: avoid;\r}\r.Parenthetical\r{\r\tmargin-left: 1.5in;\r\tmargin-right: 1.5in;\r\tpage-break-after: avoid;\r}\r.Dialogue\r{\r\tmargin-left: 1in;\r\tmargin-right: 1in;\r\torphans: 2;\r\twidows: 2;\r\tpage-break-before: avoid;\r\tpage-break-after: auto;\r}\r.DualCharacter\r{\r\tmargin-left: 1in;\r\tpage-break-before: auto;\r\tpage-break-after: avoid;\r}\r.DualParenthetical\r{\r\tmargin-left: 0.6in;\r\tmargin-right: 0.6in;\r\tpage-break-after: avoid;\r}\r.DualDialogue\r{\r\tmargin-left: 0.125in;\r\tmargin-right: 0.125in;\r\torphans: 2;\r\twidows: 2;\r\tpage-break-before: avoid;\r\tpage-break-after: auto;\r}\r#TitlePage\r{\r\tmargin-right: 1.5in;\r\tmargin-left: 1.5in;\r\ttext-align: center;\r\tmargin-top: 13pt;\r\tmargin-bottom: 0pt;\r}\r#TitlePageNotes\r{\r\tmargin-top: 13pt;\r}\r#Spacer1\r{\r\tmargin-top: 0.5in;\r}\r#Spacer2\r{\r\tmargin-top: 3in;\r}\rh1, h2, h3, h4, h5, h6\r{\r\tfont-family: serif;\r}\r.Notes\r{\r\tfont-family: serif;\r\tcolor: #777;\r}\r.Boneyard\r{\r\ttext-decoration: line-through;\r}\r/ge + endif + echo "Processing title page." + for item in fd + let s:Field = substitute(item,":.*","","g") + let s:Data = substitute(item,s:Field.":\s*","","g") + "let s:Data = substitute(item,".*:\\s*","","g") + let s:Field = substitute(s:Field," ","","g") + let s:Data = substitute(s:Data,"^\\(<br>\\|\\s\\)","","g") + let s:Data = substitute(s:Data,"/","\\\\/","g") + if s:Field == "Title" + let s:Title = s:Data + endif + exe '%s/%'.s:Field.'%/'.s:Data.'/ge' + endfor + silent exe '%s/\v\<title\>.*\<\/title\>/<title>'.substitute(s:Title,"<br>"," ","g").'<\/title>' + silent exe '%s/\v\%\w+\%//ge' + " }}} + + " CLEANING UP {{{ + silent g/^$/,/./-j + silent write + silent e + normal gg + " }}} + + endif + + echo "Thank you for using Fountain Flow for Vim." + +endfunction + +function! Flow() + if expand("%:e") =~ "\\(".g:flow_extensions."\\)" + call FountainTOhtml() + noh + nnoremap <silent> <buffer> <home> :exe 'Tex '.g:flow_directory<cr> + nnoremap <silent> <buffer> <backspace> :exe 'e '.substitute(g:flow_original," ","\\\\ ","g")<cr> + nnoremap <silent> <buffer> <delete> :exe 'tab drop '.substitute(g:flow_original," ","\\\\ ","g")<cr>:exe 'bd '.substitute(g:flow_html," ","\\\\ ","g")<cr>:exe 'call delete("'.substitute(g:flow_html," ","\\\\ ","g").'")'<cr> + nnoremap <silent> <buffer> <tab> :exe 'tab drop '.substitute(g:flow_original," ","\\\\ ","g")<cr> + nnoremap <silent> <buffer> <space> :exe 'vsplit '.substitute(g:flow_original," ","\\\\ ","g")<cr> + nnoremap <silent> <buffer> <cr> :!libreoffice --writer "%" &<cr> + nnoremap <silent> <buffer> <esc> :mapclear <buffer><cr> + else + echo "Wrong filetype. Consult :help fountainflow" + endif +endfunction +command! FF call Flow() +command! FountainFlow call Flow() +command! LibreOffice silent !libreoffice --writer "%" & +command! FlowDirectory silent exe 'Tex '.g:flow_directory + + + |