From 22b51a4b7b8209e1f84c8914a6ebf6225ff62497 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 13 Jan 2013 09:42:10 -0500 Subject: [PATCH] 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. --- posts/script/script-publish.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- 2.26.2