forked from LiveCarta/BookConverter
epub converter: prettify
This commit is contained in:
@@ -377,7 +377,7 @@ def get_tags_between_chapter_marks(first_id, href, html_soup):
|
||||
return tags
|
||||
|
||||
|
||||
def wrap_span_with_table(main_tag, old_tag):
|
||||
def wrap_preformatted_span_with_table(main_tag, old_tag):
|
||||
table = main_tag.new_tag("table")
|
||||
table.attrs['border'] = '1px solid #ccc;'
|
||||
table.attrs['style'] = 'width:100%;'
|
||||
@@ -393,7 +393,7 @@ def wrap_span_with_table(main_tag, old_tag):
|
||||
return table
|
||||
|
||||
|
||||
def wrap_block_with_table(main_tag, old_tag, color=None):
|
||||
def wrap_block_tag_with_table(main_tag, old_tag, bg_color=None):
|
||||
table = main_tag.new_tag("table")
|
||||
table.attrs['border'] = '1px solid'
|
||||
table.attrs['align'] = 'center'
|
||||
@@ -402,8 +402,8 @@ def wrap_block_with_table(main_tag, old_tag, color=None):
|
||||
tr = main_tag.new_tag("tr")
|
||||
td = main_tag.new_tag("td")
|
||||
# td.attrs['border-radius'] = '8px'
|
||||
if color:
|
||||
td.attrs['bgcolor'] = color
|
||||
if bg_color:
|
||||
td.attrs['bgcolor'] = bg_color
|
||||
old_tag.wrap(td)
|
||||
td.wrap(tr)
|
||||
tr.wrap(tbody)
|
||||
@@ -426,7 +426,7 @@ def preprocess_block_tags(chapter_tag):
|
||||
|
||||
color = '#DDDDDD' if block.attrs.get('class') == 'feature1' else None
|
||||
color = '#EEEEEE' if block.attrs.get('class') == 'feature2' else color
|
||||
wrap_block_with_table(chapter_tag, block, color)
|
||||
wrap_block_tag_with_table(chapter_tag, block, color)
|
||||
block.insert_after(BeautifulSoup(features='lxml').new_tag("br"))
|
||||
block.unwrap()
|
||||
|
||||
@@ -464,7 +464,7 @@ def preprocess_pre_tags(chapter_tag):
|
||||
"font-size: 14px; white-space: nowrap;"
|
||||
pre.insert_before(new_tag)
|
||||
pre.extract()
|
||||
table = wrap_span_with_table(chapter_tag, new_tag)
|
||||
table = wrap_preformatted_span_with_table(chapter_tag, new_tag)
|
||||
p_for_br = chapter_tag.new_tag("p")
|
||||
p_for_br.string = "\xa0"
|
||||
table.insert_after(p_for_br)
|
||||
|
||||
Reference in New Issue
Block a user