aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--screenplain/parse.py6
-rw-r--r--tests/parse_test.py45
2 files changed, 46 insertions, 5 deletions
diff --git a/screenplain/parse.py b/screenplain/parse.py
index 11856c6..9e97eed 100644
--- a/screenplain/parse.py
+++ b/screenplain/parse.py
@@ -141,9 +141,9 @@ def create_paragraph(blanks_before, line_list):
not line_list[0].endswith(TWOSPACE)
):
return _create_dialog(line_list)
- elif len(line_list) == 1 and line_list[0].endswith(':'):
- # Not according to spec, see my comment
- #http://prolost.com/blog/2011/8/9/screenplay-markdown.html?lastPage=true#comment14865294
+ elif len(line_list) == 1 and line_list[0].endswith(':') and line_list[0].isupper():
+ # TODO: need to check whether the *next* paragraph is a slug
+ # before assuming this is a transition.
return Transition(line_list)
else:
return Action(line_list)
diff --git a/tests/parse_test.py b/tests/parse_test.py
index 75d762a..1eabdb2 100644
--- a/tests/parse_test.py
+++ b/tests/parse_test.py
@@ -95,8 +95,6 @@ class ParseTests(unittest2.TestCase):
self.assertEquals([(False, 'Fuck retirement!')], dual.right.blocks)
def test_standard_transition(self):
- # Need clarification of the spec here, see
- # http://prolost.com/blog/2011/8/9/screenplay-markdown.html?lastPage=true#comment14865294
paras = list(parse.parse([
'Jack begins to argue vociferously in Vietnamese (?)',
@@ -107,5 +105,48 @@ class ParseTests(unittest2.TestCase):
]))
self.assertEquals([Action, Transition, Slug], [type(p) for p in paras])
+ def test_standard_transition(self):
+
+ paras = list(parse.parse([
+ 'Jack begins to argue vociferously in Vietnamese (?)',
+ '',
+ 'CUT TO:',
+ '',
+ "EXT. BRICK'S POOL - DAY",
+ ]))
+ self.assertEquals([Action, Transition, Slug], [type(p) for p in paras])
+
+ def test_transition_needs_to_be_upper_case(self):
+ paras = list(parse.parse([
+ 'Jack begins to argue vociferously in Vietnamese (?)',
+ '',
+ 'cut to:',
+ '',
+ "EXT. BRICK'S POOL - DAY",
+ ]))
+ self.assertEquals([Action, Action, Slug], [type(p) for p in paras])
+
+ def test_not_a_transition_on_trailing_whitespace(self):
+ paras = list(parse.parse([
+ 'Jack begins to argue vociferously in Vietnamese (?)',
+ '',
+ 'CUT TO: ',
+ '',
+ "EXT. BRICK'S POOL - DAY",
+ ]))
+ self.assertEquals([Action, Action, Slug], [type(p) for p in paras])
+
+ # Not implemented yet
+ @unittest2.expectedFailure
+ def test_transition_must_be_followed_by_slug(self):
+ paras = list(parse.parse([
+ 'Bill lights a cigarette.',
+ '',
+ 'CUT TO:',
+ '',
+ 'SOME GUY mowing the lawn.',
+ ]))
+ self.assertEquals([Action, Action, Action], [type(p) for p in paras])
+
if __name__ == '__main__':
unittest2.main()