From 29697bfe12b0e5b4dd68e4e0d7dc7032802aaade Mon Sep 17 00:00:00 2001 From: shirshasa Date: Wed, 7 Jul 2021 11:41:43 +0300 Subject: [PATCH] epub converter: fix
 4

---
 src/html_epub_preprocessor.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/html_epub_preprocessor.py b/src/html_epub_preprocessor.py
index 6a15775..c70d966 100644
--- a/src/html_epub_preprocessor.py
+++ b/src/html_epub_preprocessor.py
@@ -405,12 +405,12 @@ def preprocess_pre_tags(chapter_tag):
         for child in pre.children:
             if isinstance(child, NavigableString):
                 text = pre.text
-                text = text.replace('\t', '      ')
-                text = text.replace(' ', '  ')
+                text = text.replace('\t', "\xa0 \xa0 \xa0 ")
+                text = text.replace(' ', "\xa0 ")
                 elements = re.split('\r\n|\n|\r', text)
                 for i in elements:
                     new_tag.append(NavigableString(i))
-                    new_tag.append(BeautifulSoup().new_tag('br'))
+                    new_tag.append(BeautifulSoup(features='lxml').new_tag('br'))
             else:
                 new_tag.append(child.extract())
 
@@ -422,7 +422,7 @@ def preprocess_pre_tags(chapter_tag):
 
 
 def preprocess_code_tags(chapter_tag):
-    for code in chapter_tag.find_all("code"):
+    for code in chapter_tag.find_all(re.compile("code|kdb|var")):
         code.name = 'span'
         code.attrs['style'] = 'color:#c7254e; font-size: 14px; font-family: courier new,courier,monospace;'