aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2014-10-09 18:52:57 +0200
committerMartin Vilcans <martin@librador.com>2014-10-09 18:52:57 +0200
commit527ef777921efebf1bda6ef0ccfd724165de8477 (patch)
tree81a4d4f69b6a7856c437f27d020d5179c3a2688d
parent63843e9b485b13274a6024d34a5bd6a9c07f63e3 (diff)
downloadscreenplain-527ef777921efebf1bda6ef0ccfd724165de8477.tar.gz
Function to add one line at a time to a Dialog
This is useful for parsers that receive character, dialog and parentheticals as separate elements.
-rw-r--r--README.markdown5
-rw-r--r--screenplain/types.py9
2 files changed, 12 insertions, 2 deletions
diff --git a/README.markdown b/README.markdown
index 1979d48..90bd645 100644
--- a/README.markdown
+++ b/README.markdown
@@ -33,6 +33,11 @@ the master branch may not always work. I'm currently working on supporting
the whole [Fountain](http://fountain.io) specification. (Fountain
was previously known as "Screenplay Markdown" or "SPMD.")
+Installing
+==========
+
+ pip install screenplain
+
Credits
=======
diff --git a/screenplain/types.py b/screenplain/types.py
index f8454ef..8464ea5 100644
--- a/screenplain/types.py
+++ b/screenplain/types.py
@@ -46,10 +46,11 @@ class Section(object):
class Dialog(object):
- def __init__(self, character, lines):
+ def __init__(self, character, lines=None):
self.character = character
self.blocks = [] # list of tuples of (is_parenthetical, text)
- self._parse(lines)
+ if lines:
+ self._parse(lines)
def _parse(self, lines):
inside_parenthesis = False
@@ -60,6 +61,10 @@ class Dialog(object):
if line.endswith(')'):
inside_parenthesis = False
+ def add_line(self, line):
+ parenthetical = line.startswith('(')
+ self.blocks.append((parenthetical, line))
+
class DualDialog(object):
def __init__(self, left_dialog, right_dialog):