forked from LiveCarta/BookConverter
epub converter: fix premailer cant read namespace css
This commit is contained in:
@@ -179,6 +179,7 @@ def clean_css(css):
|
||||
|
||||
|
||||
def add_inline_style_to_html_soup(soup1, css_text):
|
||||
css_text = css_text.replace('@namespace epub "http://www.idpf.org/2007/ops";', '')
|
||||
livecarta_tmp_ids = []
|
||||
h_regex = f'(^h[1-9]$)'
|
||||
could_have_style_in_livecarta_regexp = re.compile('(^p$)|(^span$)|(^li$)|(^ul$)|(^ol$)|(^td$)|(^th$)|' + h_regex)
|
||||
@@ -186,7 +187,6 @@ def add_inline_style_to_html_soup(soup1, css_text):
|
||||
for i, x in enumerate(elements_with_possible_style_attr):
|
||||
x.attrs['livecarta_id'] = i
|
||||
livecarta_tmp_ids.append(i)
|
||||
|
||||
html_with_inline_style = transform(str(soup1), css_text=css_text,
|
||||
remove_classes=False,
|
||||
external_styles=False,
|
||||
@@ -202,8 +202,11 @@ def add_inline_style_to_html_soup(soup1, css_text):
|
||||
# if bg color is inherited, just return style as is
|
||||
for parent_tag in tag.parents:
|
||||
# white bg color not need to be checked as we do not write 'white bg color'
|
||||
if parent_tag.attrs.get('style') and ('background' in parent_tag.attrs.get('style')):
|
||||
print(tag, parent_tag.attrs.get('style'))
|
||||
tag_with_bg = ['span', 'td', 'tr', 'p']
|
||||
tag_will_be_saved = parent_tag.name in tag_with_bg
|
||||
has_bg = parent_tag.attrs.get('style') and ('background' in parent_tag.attrs.get('style'))
|
||||
if has_bg and tag_will_be_saved:
|
||||
print(tag, parent_tag.attrs.get('style'), parent_tag.name)
|
||||
return style_
|
||||
|
||||
children = tag.find_all()
|
||||
|
||||
Reference in New Issue
Block a user