From: W. Trevor King Date: Sun, 13 Jan 2013 13:06:05 +0000 (-0500) Subject: script-publish.py: Use Unicode horizontal tabs X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5b2699e76ddd31b65e23409c60c563af94433c77;p=mw2txt.git script-publish.py: Use Unicode horizontal tabs Replace the ControlCodeMatch instances with textual tabs, since they are appropriately handled in `
` blocks.
---

diff --git a/posts/script/script-publish.py b/posts/script/script-publish.py
index 4f78ac7..3c3a1ca 100755
--- a/posts/script/script-publish.py
+++ b/posts/script/script-publish.py
@@ -470,6 +470,13 @@ class ControlParser (object):
                 chunks[i] = str(chunk, self._encoding)
         return chunks
 
+    def _replace_tabs(self, chunks):
+        for i,chunk in enumerate(chunks):
+            if (isinstance(chunks[i], ControlCodeMatch) and
+                    chunks[i].control_code.name == 'horizontal tab'):
+                chunks[i] = '\t'
+        return chunks
+
     def _merge_adjacent_text(self, chunks):
         i = 1
         while i < len(chunks):
@@ -574,6 +581,7 @@ class ControlParser (object):
     def parse(self, element, text):
         chunks = self._replace_control_codes(text)
         chunks = self._decode_text(chunks)
+        chunks = self._replace_tabs(chunks)
         chunks = self._merge_adjacent_text(chunks)
         chunks = self._remove_operating_system_commands(chunks)
         chunks = self._merge_adjacent_text(chunks)