epub converter: update css_reader.py

This commit is contained in:
shirshasa
2021-09-01 16:11:52 +03:00
parent 367bb16a23
commit b708f73d89

View File

@@ -189,9 +189,9 @@ def clean_css(css):
class TagStyleConverter:
def __init__(self, tag, tag_with_style):
self.tag = tag
self.tag = tag # tag to be updated with style attribute
self.tag_initial_name = tag.name
self.tag_with_style = tag_with_style
self.tag_with_style = tag_with_style # tag with inline style parsed from css file
self.style = self.preprocess_style()
@staticmethod
@@ -227,6 +227,11 @@ class TagStyleConverter:
style = self.remove_white_if_no_bgcolor(style, self.tag_with_style)
style = style.replace('background:', 'background-color:')
style = style.replace('list-style-image', 'list-style-type')
# if tag had already had inline style, add this to style parsed from css
if self.tag.attrs.get('style') and self.tag.attrs['style'] not in style:
style += self.tag.attrs['style']
print(style)
return style
def change_attrs_with_corresponding_tags(self):