epub converter: remove list-types

This commit is contained in:
shirshasa
2021-07-09 10:35:31 +03:00
parent b6d86bcb8d
commit a5a9853b64

View File

@@ -87,8 +87,8 @@ LIVECARTA_STYLE_ATTRS = {
'border-left-width': [],
'border-bottom-width': [],
'border': [],
'list-style-type': [],
'list-style-image': []
# 'list-style-type': [],
# 'list-style-image': []
}
"""
@@ -126,8 +126,8 @@ LIVECARTA_STYLE_ATTRS_MAPPING = {
'border-right-width': lambda x: x if x != '0' else '',
'border-left-width': lambda x: x if x != '0' else '',
'border-bottom-width': lambda x: x if x != '0' else '',
'list-style-type': lambda x: x if x in list_types else 'disc',
'list-style-image': lambda x: 'disc'
# 'list-style-type': lambda x: x if x in list_types else 'disc',
# 'list-style-image': lambda x: 'disc'
}
"""
@@ -329,7 +329,7 @@ class TagStyleConverter:
@staticmethod
def add_span_to_save_style_attrs(t):
h_regex = f'(^h[1-9]$)'
no_style_in_livecarta_regexp = re.compile(r'(^ol$)|' + h_regex)
no_style_in_livecarta_regexp = re.compile(r'(^ol$)(^ul$)|' + h_regex)
if re.search(no_style_in_livecarta_regexp, t.name) and t.attrs.get('style'):
new_tag = BeautifulSoup(features='lxml').new_tag(t.name)
@@ -341,7 +341,7 @@ class TagStyleConverter:
self.tag = self.change_attrs_with_corresponding_tags()
self.wrap_p_to_save_style_attrs(self.tag)
self.add_span_to_save_style_attrs_in_li(self.tag)
self.add_span_to_save_style_attrs_in_ul(self.tag)
# self.add_span_to_save_style_attrs_in_ul(self.tag)
self.add_span_to_save_style_attrs(self.tag)
return self.tag