forked from LiveCarta/BookConverter
epub converter: fix removing <p>
This commit is contained in:
@@ -220,8 +220,12 @@ def add_inline_style_to_html_soup(soup1, css_text):
|
|||||||
style_ = style_.replace('color:white;', '')
|
style_ = style_.replace('color:white;', '')
|
||||||
return style_
|
return style_
|
||||||
|
|
||||||
def wrap_p_if_bg_color(t):
|
def wrap_p_to_save_style_attrs(t):
|
||||||
if (t.name == 'p' and t.attrs.get('style')) and ('background' in t.attrs.get('style')):
|
styles_cant_be_in_p = [attr for attr in LIVECARTA_STYLE_ATTRS if attr not in ['text-align', 'text-indent']]
|
||||||
|
|
||||||
|
if t.name == 'p' and t.attrs.get('style'):
|
||||||
|
check = [attr in t.attrs.get('style') for attr in styles_cant_be_in_p]
|
||||||
|
if any(check):
|
||||||
t.name = 'span'
|
t.name = 'span'
|
||||||
t.wrap( BeautifulSoup(features='lxml').new_tag('p'))
|
t.wrap( BeautifulSoup(features='lxml').new_tag('p'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user