From b708f73d89954681712bb183aeabaf3b15f71d23 Mon Sep 17 00:00:00 2001 From: shirshasa Date: Wed, 1 Sep 2021 16:11:52 +0300 Subject: [PATCH] epub converter: update css_reader.py --- src/css_reader.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/css_reader.py b/src/css_reader.py index bfee39a..433e841 100644 --- a/src/css_reader.py +++ b/src/css_reader.py @@ -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):