Remove processing css in lowercase

This commit is contained in:
Kiryl
2022-06-21 18:14:26 +03:00
parent 4b74faef05
commit bc4055bdaf
2 changed files with 4 additions and 4 deletions

View File

@@ -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:
"""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:
if css_rule.type == css_rule.STYLE_RULE:

View File

@@ -96,13 +96,13 @@ def str2hex(s: str):
if '#' in s and (len(s) <= 7):
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)
if match:
r, g, b = int(match.group(2)), int(match.group(3)), int(match.group(4))
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)
r, g, b = int(rgba[0]), int(rgba[1]), int(rgba[2])
if len(rgba) == 4:
@@ -110,7 +110,7 @@ def str2hex(s: str):
r, g, b = rgba2rgb(r, g, b, alpha)
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%])
match = re.search(r'hsla*\(((\d+), *(\d+)%, *(\d+)%, (\d\.\d+)*)\)', s)
if match: