diff options
-rw-r--r-- | screenplain/main.py | 1 | ||||
-rw-r--r-- | screenplain/parsers/fountain.py | 10 | ||||
-rw-r--r-- | tests/fountain_test.py | 8 |
3 files changed, 14 insertions, 5 deletions
diff --git a/screenplain/main.py b/screenplain/main.py index 2fdfb9e..57ca371 100644 --- a/screenplain/main.py +++ b/screenplain/main.py @@ -30,6 +30,7 @@ def invalid_format(parser, message): (message, ' '.join(output_formats)) ) + def main(args): parser = OptionParser(usage=usage) parser.add_option( diff --git a/screenplain/parsers/fountain.py b/screenplain/parsers/fountain.py index 4083725..6e45171 100644 --- a/screenplain/parsers/fountain.py +++ b/screenplain/parsers/fountain.py @@ -27,7 +27,7 @@ dual_dialog_re = re.compile(r'^(.+?)(\s*\^)$') slug_re = re.compile(r'(?:(\.)\s*)?(\S.*?)\s*$') scene_number_re = re.compile(r'(.*?)\s*(?:#([\w\-.]+)#)\s*$') section_re = re.compile(r'^(#{1,6})\s*([^#].*)$') -transition_re = re.compile(r'(>?)\s*(.+?)(:?)$') +transition_re = re.compile(r'(>?)\s*(.+?)(TO:)?$') def _to_rich(line_or_line_list): @@ -127,13 +127,13 @@ class InputParagraph(object): match = transition_re.match(self.lines[0]) if not match: return None - greater_than, text, colon = match.groups() + greater_than, text, to_colon = match.groups() if greater_than: - return Transition(_to_rich(text.upper() + colon)) + return Transition(_to_rich(text.upper() + (to_colon or ''))) - if text.isupper() and colon: - return Transition(_to_rich(text + colon)) + if text.isupper() and to_colon: + return Transition(_to_rich(text + to_colon)) return None diff --git a/tests/fountain_test.py b/tests/fountain_test.py index 99578cf..11a0939 100644 --- a/tests/fountain_test.py +++ b/tests/fountain_test.py @@ -217,6 +217,14 @@ class TransitionTests(unittest2.TestCase): ])) self.assertEquals([Action, Transition, Slug], [type(p) for p in paras]) + def test_transition_must_end_with_to(self): + paras = list(parse([ + 'CUT TOO:', + '', + "EXT. BRICK'S POOL - DAY", + ])) + self.assertEquals([Action, Slug], [type(p) for p in paras]) + def test_transition_needs_to_be_upper_case(self): paras = list(parse([ 'Jack begins to argue vociferously in Vietnamese (?)', |