Skip to content

Commit 814ab53

Browse files
committed
Issue #4: a parsed text can now be empty without throwing an error
1 parent 3b82513 commit 814ab53

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fountain/fountain.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ def __repr__(self):
3939

4040
class Fountain:
4141
def __init__(self, string=None, path=None):
42+
self.metadata = dict()
43+
self.elements = list()
44+
4245
if path:
4346
with open(path) as fp:
4447
self.contents = fp.read()
4548
else:
4649
self.contents = string
47-
self.parse()
50+
if self.contents != '':
51+
self.parse()
4852

4953
def parse(self):
50-
self.metadata = dict()
5154
contents = self.contents.strip().replace('\r', '')
5255
if ':' in contents.splitlines()[0]:
5356
script_head, script_body = contents.split('\n\n', 1)
@@ -74,7 +77,6 @@ def _parse_body(self, script_body):
7477
is_inside_dialogue_block = False
7578
newlines_before = 0
7679
index = -1
77-
self.elements = list()
7880
comment_text = list()
7981

8082
for linenum, line in enumerate(script_body):

0 commit comments

Comments
 (0)