From 6c4e892d32cafa6c8a78cf0ffa268b727f18a684 Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Sun, 8 Jul 2012 22:21:42 +0200 Subject: Only a single period creates a slug. Fixes #4 --- requirements.txt | 2 ++ screenplain/parsers/fountain.py | 2 +- tests/fountain_test.py | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index dd42aec..321e747 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ reportlab unittest2 +nose +pep8 diff --git a/screenplain/parsers/fountain.py b/screenplain/parsers/fountain.py index f7093cb..15b0755 100644 --- a/screenplain/parsers/fountain.py +++ b/screenplain/parsers/fountain.py @@ -28,7 +28,7 @@ title_page_value_re = re.compile(r'(?:\s{3,}|\t)(.+)') centered_re = re.compile(r'\s*>\s*(.*?)\s*<\s*$') dual_dialog_re = re.compile(r'^(.+?)(\s*\^)$') -slug_re = re.compile(r'(?:(\.)\s*)?(\S.*?)\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*(.+?)(TO:)?$') diff --git a/tests/fountain_test.py b/tests/fountain_test.py index 47bd270..02bb6be 100644 --- a/tests/fountain_test.py +++ b/tests/fountain_test.py @@ -64,6 +64,15 @@ class SlugTests(unittest2.TestCase): self.assertEquals(Slug, type(paras[0])) self.assertEquals(plain('SNIPER SCOPE POV'), paras[0].line) + def test_more_than_one_period_does_not_create_slug(self): + paras = parse([ + '..AND THEN...', + '', + ]) + self.assertEquals(1, len(paras)) + self.assertEquals(Action, type(paras[0])) + self.assertEquals(plain('..AND THEN...'), paras[0].lines[0]) + def test_scene_number_is_parsed(self): paras = parse(['EXT SOMEWHERE - DAY #42#']) self.assertEquals(plain('EXT SOMEWHERE - DAY'), paras[0].line) -- cgit