From: W. Trevor King Date: Sun, 13 Jan 2013 14:52:32 +0000 (-0500) Subject: script-publish.py: More newlines in the output HTML source X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3f1300e277fbb2a1a1eac5355b4b5094dfca8b08;p=mw2txt.git 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
. --- 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):