add background to divs

This commit is contained in:
Kiryl
2021-10-06 19:29:13 +03:00
parent b767c5901c
commit e693a77182
2 changed files with 14 additions and 5 deletions

View File

@@ -316,6 +316,15 @@ def unwrap_structural_tags(body_tag):
elif div_class in ['C441', 'C816']:
_add_table_to_abc_books(div, border='solid #6e6e70 1px', bg_color='#e7e7e8')
if div.attrs.get('style'):
if 'background-color' in div.attrs['style']:
end_index = div.attrs['style'].find('background-color') + len('background-color')
start_index_of_color = end_index + 2
bg_color = div.attrs['style'][start_index_of_color:start_index_of_color+7]
_add_table_to_abc_books(div, border='', bg_color=bg_color)
if div.attrs.get('style') == '':
del div.attrs['style']
if div.contents:
is_not_struct_tag = [child.name not in structural_tags_names for child in div.contents]
if all(is_not_struct_tag):