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;'