epub converter: fix color to all in hex 3

This commit is contained in:
shirshasa
2021-06-22 14:20:44 +03:00
parent 903f974a60
commit f3fd1a5651

View File

@@ -95,7 +95,13 @@ to suit livecarta style convention.
def get_bg_color(x): def get_bg_color(x):
color = str2hex(x) color = str2hex(x)
color = color if str2hex(x) not in ['#ffffff', '#fff'] else '' color = color if color not in ['#ffffff', '#fff'] else ''
return color
def get_text_color(x):
color = str2hex(x)
color = color if color not in ['#000000', '#000'] else ''
return color return color
@@ -106,7 +112,7 @@ LIVECARTA_STYLE_ATTRS_MAPPING = {
'font': lambda x: '', 'font': lambda x: '',
'font-family': lambda x: LawCartaConfig.font_correspondence_table.get(x.capitalize()), 'font-family': lambda x: LawCartaConfig.font_correspondence_table.get(x.capitalize()),
'font-size': convert_font_size, 'font-size': convert_font_size,
'color': str2hex, 'color': get_text_color,
'background-color': get_bg_color, 'background-color': get_bg_color,
'background': get_bg_color, 'background': get_bg_color,
'border-top-width': lambda x: x if x != '0' else '', 'border-top-width': lambda x: x if x != '0' else '',