forked from LiveCarta/BookConverter
epub converter: fix <pre> 4
This commit is contained in:
@@ -405,12 +405,12 @@ def preprocess_pre_tags(chapter_tag):
|
|||||||
for child in pre.children:
|
for child in pre.children:
|
||||||
if isinstance(child, NavigableString):
|
if isinstance(child, NavigableString):
|
||||||
text = pre.text
|
text = pre.text
|
||||||
text = text.replace('\t', ' ')
|
text = text.replace('\t', "\xa0 \xa0 \xa0 ")
|
||||||
text = text.replace(' ', ' ')
|
text = text.replace(' ', "\xa0 ")
|
||||||
elements = re.split('\r\n|\n|\r', text)
|
elements = re.split('\r\n|\n|\r', text)
|
||||||
for i in elements:
|
for i in elements:
|
||||||
new_tag.append(NavigableString(i))
|
new_tag.append(NavigableString(i))
|
||||||
new_tag.append(BeautifulSoup().new_tag('br'))
|
new_tag.append(BeautifulSoup(features='lxml').new_tag('br'))
|
||||||
else:
|
else:
|
||||||
new_tag.append(child.extract())
|
new_tag.append(child.extract())
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ def preprocess_pre_tags(chapter_tag):
|
|||||||
|
|
||||||
|
|
||||||
def preprocess_code_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.name = 'span'
|
||||||
code.attrs['style'] = 'color:#c7254e; font-size: 14px; font-family: courier new,courier,monospace;'
|
code.attrs['style'] = 'color:#c7254e; font-size: 14px; font-family: courier new,courier,monospace;'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user