aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--screenplain/parsers/spmd.py6
-rw-r--r--tests/spmd_test.py8
2 files changed, 9 insertions, 5 deletions
diff --git a/screenplain/parsers/spmd.py b/screenplain/parsers/spmd.py
index 89a457c..c1b9202 100644
--- a/screenplain/parsers/spmd.py
+++ b/screenplain/parsers/spmd.py
@@ -8,7 +8,7 @@ import re
from screenplain.types import (
Slug, Action, Dialog, DualDialog, Transition
)
-from screenplain.richstring import parse_emphasis
+from screenplain.richstring import parse_emphasis, plain
slug_regexes = (
re.compile(r'^(INT|EXT|EST)[ .]'),
@@ -21,7 +21,7 @@ TWOSPACE = ' ' * 2
centered_re = re.compile(r'\s*>\s*(.*?)\s*<\s*$')
dual_dialog_re = re.compile(r'^(.+?)(\s*\^)$')
slug_re = re.compile(r'(?:(\.)\s*)?(\S.*?)\s*$')
-scene_number_re = re.compile(r'(.*?)\s*(?:#([^#]+)#)\s*$')
+scene_number_re = re.compile(r'(.*?)\s*(?:#([\w\-.]+)#)\s*$')
transition_re = re.compile(r'(>?)\s*(.+?)(:?)$')
@@ -68,7 +68,7 @@ class InputParagraph(object):
match = scene_number_re.match(text)
if match:
text, scene_number = match.groups()
- return Slug(_to_rich(text), _to_rich(scene_number))
+ return Slug(_to_rich(text), plain(scene_number))
else:
return Slug(_to_rich(text))
diff --git a/tests/spmd_test.py b/tests/spmd_test.py
index b317b56..21f39ae 100644
--- a/tests/spmd_test.py
+++ b/tests/spmd_test.py
@@ -72,9 +72,13 @@ class ParseTests(unittest2.TestCase):
self.assertEquals(plain('42'), paras[0].scene_number)
self.assertEquals(plain('INT ROOM #237'), paras[0].line)
- def test_scene_number_can_be_styled(self):
+ def test_scene_number_must_be_alphanumeric(self):
paras = parse(['.SOMEWHERE #*HELLO*#'])
- self.assertEquals(italic('HELLO'), paras[0].scene_number)
+ self.assertIsNone(paras[0].scene_number)
+ self.assertEquals(
+ (plain)(u'SOMEWHERE #') + (italic)(u'HELLO') + (plain)(u'#'),
+ paras[0].line
+ )
# A Character element is any line entirely in caps, with one empty
# line before it and without an empty line after it.