forked from LiveCarta/BookConverter
Add inches->px converter
This commit is contained in:
@@ -57,7 +57,7 @@ class CSSPreprocessor:
|
||||
def convert_tag_style_values(size_value: str, is_indent: bool = False) -> str:
|
||||
"""
|
||||
Function
|
||||
- converts values of tags from em/%/pt to px
|
||||
- converts values of tags from em/%/pt/in to px
|
||||
- find closest font-size px
|
||||
Parameters
|
||||
----------
|
||||
@@ -71,7 +71,7 @@ class CSSPreprocessor:
|
||||
converted value size
|
||||
"""
|
||||
size_regexp = re.compile(
|
||||
r"(^-*(\d*\.*\d+)%$)|(^-*(\d*\.*\d+)em$)|(^-*(\d*\.*\d+)pt$)")
|
||||
r"(^-*(\d*\.*\d+)%$)|(^-*(\d*\.*\d+)em$)|(^-*(\d*\.*\d+)pt$)|(^-*(\d*\.*\d+)in$)")
|
||||
has_style_attrs = re.search(size_regexp, size_value)
|
||||
if has_style_attrs:
|
||||
if has_style_attrs.group(1):
|
||||
@@ -85,6 +85,9 @@ class CSSPreprocessor:
|
||||
elif has_style_attrs.group(5):
|
||||
size_value = float(size_value.replace("pt", "")) * 4/3
|
||||
return str(size_value)+'px'
|
||||
elif has_style_attrs.group(7):
|
||||
size_value = float(size_value.replace("in", "")) * 96
|
||||
return str(size_value)+'px'
|
||||
else:
|
||||
return ""
|
||||
return size_value
|
||||
|
||||
Reference in New Issue
Block a user