diff options
author | Martin Vilcans <martin@librador.com> | 2011-08-24 01:11:59 +0200 |
---|---|---|
committer | Martin Vilcans <martin@librador.com> | 2011-08-24 01:11:59 +0200 |
commit | 471fda12cf496f3bee4aa3aad7e04a2cc7073c8a (patch) | |
tree | ebd8c1648cfa7ac325b93551eed7898752cc24b1 | |
parent | cd6a0be01d0f09faa55760769a9beee011599240 (diff) | |
download | screenplain-471fda12cf496f3bee4aa3aad7e04a2cc7073c8a.tar.gz |
New spec for transitions.
The rule that a transition must be followed by a slug is not implemented.
-rw-r--r-- | screenplain/parse.py | 6 | ||||
-rw-r--r-- | tests/parse_test.py | 45 |
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() |