Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions screenplain/parsers/fountain.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
title_page_key_re = re.compile(r'([^:]+):\s*(.*)')
title_page_value_re = re.compile(r'(?:\s{3,}|\t)(.+)')

character_re = re.compile(
r"^[^a-z]*[A-Z][^a-z]*([ \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*$')
scene_number_re = re.compile(r'(.*?)\s*(?:#([\w\-.]+)#)\s*$')
section_re = re.compile(r'^(#{1,6})\s*([^#].*)$')
Expand Down Expand Up @@ -134,14 +136,15 @@ def append_dialog(self, paragraphs):
return False
if character.startswith('@') and len(character) >= 2:
character = character[1:]
elif not character.isupper():
elif not character_re.match(character):
return False

if paragraphs and isinstance(paragraphs[-1], Dialog):
dual_match = dual_dialog_re.match(character)
dual_match = character.rstrip().endswith('^')
if dual_match:
character = character.rstrip()[:-1] # remove the caret
previous = paragraphs.pop()
dialog = self._create_dialog(dual_match.group(1))
dialog = self._create_dialog(character)
paragraphs.append(DualDialog(previous, dialog))
return True

Expand Down
5 changes: 5 additions & 0 deletions tests/files/dialogue-parentheticals.fountain
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GIRL
Let me tell you something.

GUY (On the phone)
I don't wanna.
2 changes: 2 additions & 0 deletions tests/files/dialogue-parentheticals.fountain.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div class="dialog"><p class="character">GIRL</p><p>Let me tell you something.</p></div>
<div class="dialog"><p class="character">GUY (On the phone)</p><p>I don't wanna.</p></div>