forked from LiveCarta/BookConverter
Fix bag 4622 + indents
This commit is contained in:
@@ -231,8 +231,21 @@ class TagStyleConverter:
|
||||
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']
|
||||
# hot_fix
|
||||
negative_text_indent_regexp = re.compile(r'((text-indent:( *-\w+%*);) *(margin-left:( *\w+%*);))|(text-indent:( *-\w+%*);)')
|
||||
inline_style = self.tag.attrs['style']
|
||||
has_inline_style_attrs = re.search(negative_text_indent_regexp, inline_style)
|
||||
has_css_style_attrs = re.search(negative_text_indent_regexp, style)
|
||||
if has_inline_style_attrs:
|
||||
if has_inline_style_attrs.group(1):
|
||||
inline_style = inline_style.replace(has_inline_style_attrs.group(1), 'text-indent: ' + has_inline_style_attrs.group(5))
|
||||
style = style.replace(has_css_style_attrs.group(1), '')
|
||||
if has_inline_style_attrs.group(6):
|
||||
inline_style = inline_style.replace(has_inline_style_attrs.group(6), '')
|
||||
style = style.replace(has_css_style_attrs.group(6), '')
|
||||
style += inline_style
|
||||
|
||||
return style
|
||||
|
||||
|
||||
Reference in New Issue
Block a user