aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2012-02-20 00:14:58 +0100
committerMartin Vilcans <martin@librador.com>2012-02-20 00:14:58 +0100
commit10908e9db218ecd4dbdeeb704269e2dabffb72a5 (patch)
treee2d2e537fd2e538d5d064dc208cf9112fe6b9e9a
parent84d6de1f11cee777e9d256b1e170794b58c3c08c (diff)
downloadscreenplain-10908e9db218ecd4dbdeeb704269e2dabffb72a5.tar.gz
Added commenting out using /* boneyard */
-rw-r--r--screenplain/main.py4
-rw-r--r--screenplain/parsers/fountain.py15
-rw-r--r--tests/files/boneyard.fountain22
-rw-r--r--tests/files/boneyard.fountain.html4
-rw-r--r--tests/files_test.py6
-rw-r--r--tests/fountain_test.py7
6 files changed, 54 insertions, 4 deletions
diff --git a/screenplain/main.py b/screenplain/main.py
index 57ca371..720bf50 100644
--- a/screenplain/main.py
+++ b/screenplain/main.py
@@ -9,7 +9,7 @@ import sys
import codecs
from optparse import OptionParser
-from screenplain.parsers.fountain import parse
+from screenplain.parsers import fountain
output_formats = (
'fdx', 'html'
@@ -75,7 +75,7 @@ def main(args):
input = codecs.open(input_file, 'r', 'utf-8')
else:
input = codecs.getreader('utf-8')(sys.stdin)
- screenplay = parse(input)
+ screenplay = fountain.parse(input)
if format == 'pdf':
from screenplain.export.pdf import to_pdf
diff --git a/screenplain/parsers/fountain.py b/screenplain/parsers/fountain.py
index 6e45171..698ede1 100644
--- a/screenplain/parsers/fountain.py
+++ b/screenplain/parsers/fountain.py
@@ -17,8 +17,12 @@ slug_regexes = (
re.compile(r'^I/E[ .]'),
)
+boneyard_re = re.compile(r'/\*.*?\*/', flags=re.DOTALL)
+
TWOSPACE = ' ' * 2
+linebreak_re = re.compile('\r\n|\n|\r')
+
title_page_key_re = re.compile(r'([^:]+):\s*(.*)')
title_page_value_re = re.compile(r'(?:\s{3,}|\t)(.+)')
@@ -168,8 +172,17 @@ def _is_blank(line):
return line == ''
-def parse(source):
+def parse(stream):
+ content = stream.read()
+ content = boneyard_re.sub('', content)
+ lines = linebreak_re.split(content)
+ del content
+ return parse_lines(lines)
+
+
+def parse_lines(source):
"""Reads raw text input and generates paragraph objects."""
+
source = (_preprocess_line(line) for line in source)
title_page_lines = list(takewhile(lambda line: line != '', source))
diff --git a/tests/files/boneyard.fountain b/tests/files/boneyard.fountain
new file mode 100644
index 0000000..3d3adc2
--- /dev/null
+++ b/tests/files/boneyard.fountain
@@ -0,0 +1,22 @@
+As he rattles off the long list, Brick and Steel share a look. This is going to be BAD.
+
+CUT TO:
+/*
+INT. GARAGE - DAY
+
+BRICK and STEEL get into Mom's PORSCHE, Steel at the wheel. They pause for a beat, the gravity of the situation catching up with them.
+
+BRICK
+This is everybody we've ever put away.
+
+STEEL
+(starting the engine)
+So much for retirement!
+
+They speed off. To destiny!
+
+CUT TO:
+*/
+EXT. PALATIAL MANSION - DAY
+
+An EXTREMELY HANDSOME MAN drinks a beer. Shirtless, unfortunately.
diff --git a/tests/files/boneyard.fountain.html b/tests/files/boneyard.fountain.html
new file mode 100644
index 0000000..291581b
--- /dev/null
+++ b/tests/files/boneyard.fountain.html
@@ -0,0 +1,4 @@
+<div class="action"><p>As he rattles off the long list, Brick and Steel share a look.&nbsp; This is going to be BAD.</p></div>
+<div class="transition">CUT TO:</div>
+<h6>EXT. PALATIAL MANSION - DAY</h6>
+<div class="action"><p>An EXTREMELY HANDSOME MAN drinks a beer.&nbsp; Shirtless, unfortunately.</p></div>
diff --git a/tests/files_test.py b/tests/files_test.py
index 0f0cba0..46eb349 100644
--- a/tests/files_test.py
+++ b/tests/files_test.py
@@ -70,3 +70,9 @@ class ParseTests(unittest2.TestCase):
'sections.fountain', 'sections.html',
'sections.fountain.html', '--bare')
self.assertMultiLineEqual(expected, actual)
+
+ def test_boneyard(self):
+ actual, expected = self.convert(
+ 'boneyard.fountain', 'sections.html',
+ 'boneyard.fountain.html', '--bare')
+ self.assertMultiLineEqual(expected, actual)
diff --git a/tests/fountain_test.py b/tests/fountain_test.py
index 11a0939..5b1d386 100644
--- a/tests/fountain_test.py
+++ b/tests/fountain_test.py
@@ -3,12 +3,17 @@
# http://www.opensource.org/licenses/mit-license.php
import unittest2
-from screenplain.parsers.fountain import parse
from screenplain.parsers import fountain
from screenplain.types import (
Slug, Action, Dialog, DualDialog, Transition, Section
)
from screenplain.richstring import plain, italic, empty_string
+from StringIO import StringIO
+
+
+def parse(lines):
+ content = '\n'.join(lines)
+ return fountain.parse(StringIO(content))
class SlugTests(unittest2.TestCase):