forked from LiveCarta/BookConverter
Remove processing css in lowercase
This commit is contained in:
@@ -215,7 +215,7 @@ def update_css_styles_to_livecarta_convention(css_rule: cssutils.css.CSSStyleRul
|
|||||||
|
|
||||||
def build_css_file_content(css_content: str) -> str:
|
def build_css_file_content(css_content: str) -> str:
|
||||||
"""Build css content with livecarta convention"""
|
"""Build css content with livecarta convention"""
|
||||||
sheet = cssutils.parseString(css_content.lower(), validate=False)
|
sheet = cssutils.parseString(css_content, validate=False)
|
||||||
|
|
||||||
for css_rule in sheet:
|
for css_rule in sheet:
|
||||||
if css_rule.type == css_rule.STYLE_RULE:
|
if css_rule.type == css_rule.STYLE_RULE:
|
||||||
|
|||||||
@@ -96,13 +96,13 @@ def str2hex(s: str):
|
|||||||
if '#' in s and (len(s) <= 7):
|
if '#' in s and (len(s) <= 7):
|
||||||
return s.lower()
|
return s.lower()
|
||||||
|
|
||||||
if ('rgb' in s) and ('%' in s):
|
if ('rgb' in s.lower()) and ('%' in s):
|
||||||
match = re.search(r'rgba*\(((\d+)%, *(\d+)%, *(\d+)%(, \d\.\d+)*)\)', s)
|
match = re.search(r'rgba*\(((\d+)%, *(\d+)%, *(\d+)%(, \d\.\d+)*)\)', s)
|
||||||
if match:
|
if match:
|
||||||
r, g, b = int(match.group(2)), int(match.group(3)), int(match.group(4))
|
r, g, b = int(match.group(2)), int(match.group(3)), int(match.group(4))
|
||||||
return rgb_percent_to_hex((r, g, b))
|
return rgb_percent_to_hex((r, g, b))
|
||||||
|
|
||||||
if 'rgb' in s:
|
if 'rgb' in s.lower():
|
||||||
rgba = re.findall('([0-9] *\.?[0-9]+)', s)
|
rgba = re.findall('([0-9] *\.?[0-9]+)', s)
|
||||||
r, g, b = int(rgba[0]), int(rgba[1]), int(rgba[2])
|
r, g, b = int(rgba[0]), int(rgba[1]), int(rgba[2])
|
||||||
if len(rgba) == 4:
|
if len(rgba) == 4:
|
||||||
@@ -110,7 +110,7 @@ def str2hex(s: str):
|
|||||||
r, g, b = rgba2rgb(r, g, b, alpha)
|
r, g, b = rgba2rgb(r, g, b, alpha)
|
||||||
return rgb_to_hex((r, g, b))
|
return rgb_to_hex((r, g, b))
|
||||||
|
|
||||||
if 'hsl' in s:
|
if 'hsl' in s.lower():
|
||||||
# hsl(hue in {0,360}, saturation [0, 100%], lightness [0, 100%])
|
# hsl(hue in {0,360}, saturation [0, 100%], lightness [0, 100%])
|
||||||
match = re.search(r'hsla*\(((\d+), *(\d+)%, *(\d+)%, (\d\.\d+)*)\)', s)
|
match = re.search(r'hsla*\(((\d+), *(\d+)%, *(\d+)%, (\d\.\d+)*)\)', s)
|
||||||
if match:
|
if match:
|
||||||
|
|||||||
Reference in New Issue
Block a user