From 815a2c80c88bf78afc15caa7f2389ee155b5020f Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Thu, 21 Feb 2019 21:27:47 +0100 Subject: Do not create empty paragraph if Note is a full paragraph --- screenplain/parsers/fountain.py | 2 ++ tests/files/notes.fountain | 14 ++++++++++++++ tests/files/notes.fountain.html | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/screenplain/parsers/fountain.py b/screenplain/parsers/fountain.py index 1a72aa7..c2f6d71 100644 --- a/screenplain/parsers/fountain.py +++ b/screenplain/parsers/fountain.py @@ -255,6 +255,8 @@ def parse_body(source): for blank, input_lines in itertools.groupby(source, _is_blank): if not blank: as_string = note_re.sub('', '\n'.join(input_lines)) + if _is_blank(as_string): + continue paragraph = InputParagraph(as_string.split('\n')) paragraph.update_list(paragraphs) diff --git a/tests/files/notes.fountain b/tests/files/notes.fountain index 1e68fd2..f72b4fc 100644 --- a/tests/files/notes.fountain +++ b/tests/files/notes.fountain @@ -16,3 +16,17 @@ a proper note because it contains a blank line ]] + +Before full paragraph note + +[[Note as its own paragraph does not generate an empty paragraph]] + +After full paragraph note + +Before multi-paragraph note + +[[Note as its own paragraph +on several lines +does not generate an empty paragraph]] + +After multi-paragraph note diff --git a/tests/files/notes.fountain.html b/tests/files/notes.fountain.html index 033f63c..f9558bc 100644 --- a/tests/files/notes.fountain.html +++ b/tests/files/notes.fountain.html @@ -4,3 +4,7 @@

Multiple on one

This is not [[
a proper note

because it contains a blank line
]]

+

Before full paragraph note

+

After full paragraph note

+

Before multi-paragraph note

+

After multi-paragraph note

-- cgit v1.2.3