From 527ef777921efebf1bda6ef0ccfd724165de8477 Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Thu, 9 Oct 2014 18:52:57 +0200 Subject: 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. --- README.markdown | 5 +++++ screenplain/types.py | 9 +++++++-- 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): -- cgit v1.2.3