From 5b2699e76ddd31b65e23409c60c563af94433c77 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 13 Jan 2013 08:06:05 -0500 Subject: [PATCH] script-publish.py: Use Unicode horizontal tabs Replace the ControlCodeMatch instances with textual tabs, since they are appropriately handled in `
` blocks.
---
 posts/script/script-publish.py | 8 ++++++++
 1 file changed, 8 insertions(+)

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)
-- 
2.26.2