From: W. Trevor King Date: Sun, 13 Jan 2013 14:42:10 +0000 (-0500) Subject: script-publish.py: Drop empty text chunks X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=22b51a4b7b8209e1f84c8914a6ebf6225ff62497;p=mw2txt.git script-publish.py: Drop empty text chunks Firefox 10.0.11 was having trouble with: Which, instead of being a no-op, was changing the default styling of every element after that tag. --- diff --git a/posts/script/script-publish.py b/posts/script/script-publish.py index b772e8b..bd64c81 100755 --- a/posts/script/script-publish.py +++ b/posts/script/script-publish.py @@ -492,6 +492,15 @@ class ControlParser (object): i += 1 return chunks + def _drop_empty_text(self, chunks): + i = 0 + while i < len(chunks): + if isinstance(chunks[i], str) and not chunks[i]: + chunks.pop(i) + else: + i += 1 + return chunks + def _remove_operating_system_commands(self, chunks): i = 0 while i < len(chunks): @@ -600,6 +609,7 @@ class ControlParser (object): chunks = self._drop_clear_line(chunks) chunks = self._collapse_adjacent_newlines(chunks) chunks = self._merge_adjacent_text(chunks) + chunks = self._drop_empty_text(chunks) chunks = self._style_chunks(chunks) previous = element last_chunk = None