diff --git a/src/html_presets_processor.py b/src/html_presets_processor.py
index 1af982d..d6206bf 100644
--- a/src/html_presets_processor.py
+++ b/src/html_presets_processor.py
@@ -180,7 +180,6 @@ class HtmlPresetsProcessor:
def _unwrap_tag(self, **kwargs):
if kwargs["found_tag"].parent:
self.set_attrs_to_parent(kwargs["found_tag"], kwargs["found_tag"].parent)
- print(kwargs["found_tag"])
kwargs["found_tag"].unwrap()
@staticmethod
diff --git a/src/inline_style_processor.py b/src/inline_style_processor.py
index 08b2f08..8985206 100644
--- a/src/inline_style_processor.py
+++ b/src/inline_style_processor.py
@@ -84,50 +84,39 @@ class InlineStyleProcessor:
to value and divisible by m
"""
# Find the quotient
- q = int(value / m)
+ q = round(value / m)
+ return m * q
- n1 = m * q
- n2 = (m * (q + 1))
-
- new_value = n1 if (abs(value - n1) < abs(value - n2)) else n2
- return new_value
-
- processed_style = ";".join(split_style)+';'
+ processed_style = ";".join(split_style) + ';'
margin_left_regexp = re.compile(
- r"((margin-left|margin): *-*(\d*\.*\d+)\w+;*)")
+ r"(margin(-left)?:\s*-?(\d+(\.\d+)?)(\w*)\s*;)")
text_indent_regexp = re.compile(
- r"(text-indent: *-*(\d*\.*\d+)\w+;*)")
+ r"(text-indent:\s*-?(\d+(\.\d+)?)(\w*)\s*;)")
+
+ has_margin = margin_left_regexp.search(processed_style)
+ has_text_indent = text_indent_regexp.search(processed_style)
- has_margin = re.search(margin_left_regexp, processed_style)
- has_text_indent = re.search(text_indent_regexp, processed_style)
if has_margin:
- num_m = abs(int("0" + "".join(
- filter(str.isdigit, str(has_margin.group(3))))))
+ num_m = abs(float(has_margin.group(3)))
if has_text_indent:
- num_ti = abs(int("0" + "".join(
- filter(str.isdigit, str(has_text_indent.group(2))))))
+ num_ti = abs(float(has_text_indent.group(2)))
indent_value = str(closest_number(abs(num_m - num_ti)))
- processed_style = processed_style.replace(has_text_indent.group(1), "text-indent: " +
- indent_value + "px; ")
processed_style = processed_style.replace(
- has_margin.group(1), "")
- return processed_style
+ has_text_indent.group(0), f"text-indent: {indent_value}px;")
+ else:
+ indent_value = str(closest_number(abs(num_m)))
+ processed_style += f"text-indent: {indent_value}px;"
- indent_value = str(closest_number(abs(num_m)))
- processed_style = processed_style.replace(has_margin.group(1), "text-indent: " +
- indent_value + "px; ")
- return processed_style
+ processed_style = margin_left_regexp.sub("", processed_style)
elif has_text_indent:
- num_ti = abs(int("0" + "".join(
- filter(str.isdigit, str(has_text_indent.group(2))))))
+ num_ti = abs(float(has_text_indent.group(2)))
indent_value = str(closest_number(num_ti))
- processed_style = processed_style.replace(has_text_indent.group(1), "text-indent: " +
- indent_value + "px; ")
- return processed_style
- return processed_style
+ processed_style = text_indent_regexp.sub(f"text-indent: {indent_value}px;", processed_style)
+
+ return processed_style.strip(";")
def process_inline_style(self) -> str:
"""