From aa4119ced837d772cd11a81fd342ea2c5513fb6f Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Thu, 21 Feb 2019 21:19:47 +0100 Subject: Add supports for notes Fixes #37 --- screenplain/parsers/fountain.py | 4 +++- tests/files/notes.fountain | 18 ++++++++++++++++++ tests/files/notes.fountain.html | 6 ++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/files/notes.fountain create mode 100644 tests/files/notes.fountain.html diff --git a/screenplain/parsers/fountain.py b/screenplain/parsers/fountain.py index 5434c1a..9780982 100644 --- a/screenplain/parsers/fountain.py +++ b/screenplain/parsers/fountain.py @@ -35,6 +35,7 @@ scene_number_re = re.compile(r'(.*?)\s*(?:#([\w\-.]+)#)\s*$') section_re = re.compile(r'^(#{1,6})\s*([^#].*)$') transition_re = re.compile(r'(>?)\s*(.+?)(TO:)?$') page_break_re = re.compile(r'^={3,}$') +note_re = re.compile(r'\[\[.*?\]\]', re.DOTALL) def _sequence_to_rich(lines): @@ -253,7 +254,8 @@ def parse_body(source): paragraphs = [] for blank, input_lines in itertools.groupby(source, _is_blank): if not blank: - paragraph = InputParagraph(list(input_lines)) + as_string = note_re.sub('', '\n'.join(input_lines)) + paragraph = InputParagraph(as_string.split('\n')) paragraph.update_list(paragraphs) return paragraphs diff --git a/tests/files/notes.fountain b/tests/files/notes.fountain new file mode 100644 index 0000000..1e68fd2 --- /dev/null +++ b/tests/files/notes.fountain @@ -0,0 +1,18 @@ +Before1 [[some notes]]After1 + +Before2 [[multiline +note +here]]After2 + +Before3 [[multiline +note + +with a blank line]]After3 + +Multiple [[notes]]on one[[line]] + +This is not [[ +a proper note + +because it contains a blank line +]] diff --git a/tests/files/notes.fountain.html b/tests/files/notes.fountain.html new file mode 100644 index 0000000..033f63c --- /dev/null +++ b/tests/files/notes.fountain.html @@ -0,0 +1,6 @@ +

Before1 After1

+

Before2 After2

+

Before3 After3

+

Multiple on one

+

This is not [[
a proper note

+

because it contains a blank line
]]

-- cgit