From 6f18e8e4a2108d2215250b9b3a4a8b37d1bb0107 Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Thu, 26 Jan 2017 10:43:04 +1100 Subject: [PATCH] remove .prettify() @ pre_with_pr (bs4); fix spaces in tables too --- MLPApi.py | 1 + default.css | 2 +- functions.py | 13 +------------ lib/pre_tables.py | 3 ++- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/MLPApi.py b/MLPApi.py index 4d75115..258750d 100644 --- a/MLPApi.py +++ b/MLPApi.py @@ -69,6 +69,7 @@ def markdown2html(md, basepath): # exception, again, because
 aren't supported by the phantoms
     html = html.replace(' espace;', '.')
     html = replace_img_src_base64(html, basepath=os.path.dirname(basepath))
+    sublime.set_clipboard(html)
     return html
 
 def show_html(md_view, preview):
diff --git a/default.css b/default.css
index 2599680..25cb52d 100644
--- a/default.css
+++ b/default.css
@@ -37,7 +37,7 @@ pre {
     border-radius: 3px;
 }
 pre code {
-    padding-left: 0;
+    padding: 0;
 }
 
 pre code .space {
diff --git a/functions.py b/functions.py
index 0700d04..82cc08a 100644
--- a/functions.py
+++ b/functions.py
@@ -96,15 +96,4 @@ def pre_with_br(html):
         code = pre.find('code')
         code.replaceWith(BeautifulSoup(''.join(str(node) for node in pre.contents) \
                       .replace('\n', '
').replace(' ', '.'), 'html.parser')) - return soup.prettify().replace('
', '
') - - while True: - obj = re.search(r'
(.*?)
', html, re.DOTALL) - if not obj: - break - html = list(html) - html[obj.start(0):obj.end(0)] = '
' + ''.join(html[obj.start(1):obj.end(1)]) \
-                                            .replace('\n', '
') \ - .replace(' ', ' ') + '
' - html = ''.join(html) - return html + return str(soup).replace('
', '
') diff --git a/lib/pre_tables.py b/lib/pre_tables.py index 29cb849..0af7c64 100644 --- a/lib/pre_tables.py +++ b/lib/pre_tables.py @@ -56,7 +56,8 @@ def pre_table(s_table): text = '
'
     for i, row in enumerate(rows):
         for j, cell in enumerate(row):
-            text += '| ' + ''.join(str(node) for node in cell.contents) + ' ' * (cols_width[j] - len(cell.text))
+            text += '| ' + ''.join(str(node) for node in cell.contents) \
+                    + ' ' * (cols_width[j] - len(cell.text) + 1)
         text += '|\n'
     text += '
' return text