From 3f1300e277fbb2a1a1eac5355b4b5094dfca8b08 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 13 Jan 2013 09:52:32 -0500 Subject: [PATCH] script-publish.py: More newlines in the output HTML source These newlines don't affect the rendered HTML, but they make the HTML source more readable. The `previous_tail` bit keeps unstyled text from clobbering newlines that were attached to a preceding
. --- posts/script/script-publish.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/posts/script/script-publish.py b/posts/script/script-publish.py index d1c74ba..622098d 100755 --- a/posts/script/script-publish.py +++ b/posts/script/script-publish.py @@ -639,8 +639,9 @@ class ControlParser (object): except ValueError as e: raise ValueError(repr(chunk.text)) from e else: + previous_tail = previous.tail or '' try: - previous.tail = chunk.text + previous.tail = previous_tail + chunk.text except ValueError as e: raise ValueError(repr(chunk.text)) from e elif isinstance(chunk, ControlCodeMatch): @@ -677,7 +678,7 @@ class ScriptParser (object): body.append(pre) tree = _etree.ElementTree(element=html) html.text = html.tail = head.text = head.tail = '\n' - body.text = body.tail = '\n' + body.text = body.tail = pre.tail = '\n' return tree def process(self, source, output=None): -- 2.26.2