forked from LiveCarta/BookConverter
epub converter: fix colors, style in <pre>
This commit is contained in:
@@ -501,15 +501,20 @@ 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
|
cleaned_text = _prepare_formatted(pre.text)
|
||||||
text = _prepare_formatted(text)
|
sub_strings = re.split('\r\n|\n|\r', cleaned_text)
|
||||||
elements = re.split('\r\n|\n|\r', text)
|
for string in sub_strings:
|
||||||
for i in elements:
|
new_tag.append(NavigableString(string))
|
||||||
new_tag.append(NavigableString(i))
|
|
||||||
new_tag.append(BeautifulSoup(features='lxml').new_tag('br'))
|
new_tag.append(BeautifulSoup(features='lxml').new_tag('br'))
|
||||||
else:
|
else:
|
||||||
child.string = _prepare_formatted(child.text)
|
for sub_child in child.children:
|
||||||
new_tag.append(child.extract())
|
if isinstance(sub_child, NavigableString):
|
||||||
|
cleaned_text2 = _prepare_formatted(str(sub_child))
|
||||||
|
sub_child.replace_with(NavigableString(cleaned_text2))
|
||||||
|
else:
|
||||||
|
sub_child.string = _prepare_formatted(sub_child.text)
|
||||||
|
cleaned_tag = child.extract()
|
||||||
|
new_tag.append(cleaned_tag)
|
||||||
if to_add_br:
|
if to_add_br:
|
||||||
new_tag.append(BeautifulSoup(features='lxml').new_tag('br'))
|
new_tag.append(BeautifulSoup(features='lxml').new_tag('br'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user