aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2011-11-15 22:53:50 +0100
committerMartin Vilcans <martin@librador.com>2011-11-15 22:53:50 +0100
commitdcf91bd828ba66e3682ed08bee38e85a5a5ae7ba (patch)
treef3216e39624451fc3d72f1cacfabfa73733e0c34
parentddda345a77ee4232002e5179b3ba7992a112af76 (diff)
downloadscreenplain-dcf91bd828ba66e3682ed08bee38e85a5a5ae7ba.tar.gz
Make sure upper case centered paragraph isn't parsed as dialogue.
-rw-r--r--screenplain/parsers/spmd.py13
-rw-r--r--tests/spmd_test.py9
2 files changed, 15 insertions, 7 deletions
diff --git a/screenplain/parsers/spmd.py b/screenplain/parsers/spmd.py
index 7b0f361..2d101ac 100644
--- a/screenplain/parsers/spmd.py
+++ b/screenplain/parsers/spmd.py
@@ -64,7 +64,11 @@ def _to_rich(line_list):
def create_paragraph(blanks_before, line_list):
if is_slug(blanks_before, line_list):
return Slug(_to_rich(line_list))
- if (
+ elif all(centered_re.match(line) for line in line_list):
+ return Action(_to_rich(
+ centered_re.match(line).group(1) for line in line_list
+ ), centered=True)
+ elif (
len(line_list) > 1 and
line_list[0].isupper() and
not line_list[0].endswith(TWOSPACE)
@@ -78,12 +82,7 @@ def create_paragraph(blanks_before, line_list):
# later if we find that it's not followed by a slug.
return Transition(_to_rich(line_list))
else:
- if all(centered_re.match(line) for line in line_list):
- return Action(_to_rich(
- centered_re.match(line).group(1) for line in line_list
- ), centered=True)
- else:
- return Action(_to_rich(line_list))
+ return Action(_to_rich(line_list))
def clean_line(line):
diff --git a/tests/spmd_test.py b/tests/spmd_test.py
index f1c62bf..d5a4615 100644
--- a/tests/spmd_test.py
+++ b/tests/spmd_test.py
@@ -222,6 +222,15 @@ class ParseTests(unittest2.TestCase):
self.assertEquals([Action], [type(p) for p in paras])
self.assertTrue(paras[0].centered)
+ def test_upper_case_centered_not_parsed_as_dialog(self):
+ paras = list(parse([
+ '> FIRST! <',
+ ' > SECOND! <',
+ '> THIRD! <',
+ ]))
+ self.assertEquals([Action], [type(p) for p in paras])
+ self.assertTrue(paras[0].centered)
+
def test_centering_marks_in_middle_of_paragraphs_are_verbatim(self):
paras = list(parse([
'first!',