forked from LiveCarta/BookConverter
comment duplicate_styles_check cause of transform
This commit is contained in:
@@ -229,7 +229,6 @@ class HtmlEpubPreprocessor:
|
|||||||
Chapter Tag with inserted tags
|
Chapter Tag with inserted tags
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def insert(tag, tag_to_insert):
|
def insert(tag, tag_to_insert):
|
||||||
# insert all items that was in tag to subtag and remove from tag
|
# insert all items that was in tag to subtag and remove from tag
|
||||||
for content in reversed(tag.contents):
|
for content in reversed(tag.contents):
|
||||||
@@ -48,15 +48,18 @@ class TagInlineStyleProcessor:
|
|||||||
style_ = style_.replace("color:white;", "")
|
style_ = style_.replace("color:white;", "")
|
||||||
return style_
|
return style_
|
||||||
|
|
||||||
@staticmethod
|
# @staticmethod
|
||||||
def duplicate_styles_check(split_style: list) -> list:
|
# def duplicate_styles_check(split_style: list) -> list:
|
||||||
style_name2style_value = {}
|
# style_name2style_value = {}
|
||||||
for list_item in split_style:
|
# # {key: val for for list_item in split_style}
|
||||||
key, val = list_item.split(":")
|
# splitstrs = (list_item.split(":") for list_item in split_style)
|
||||||
if val not in style_name2style_value.keys():
|
# d = {key: val for key, val in splitstrs}
|
||||||
style_name2style_value[key] = val
|
# for list_item in split_style:
|
||||||
split_style = [k + ":" + v for k, v in style_name2style_value.items()]
|
# key, val = list_item.split(":")
|
||||||
return split_style
|
# if key not in style_name2style_value.keys():
|
||||||
|
# style_name2style_value[key] = val
|
||||||
|
# split_style = [k + ":" + v for k, v in style_name2style_value.items()]
|
||||||
|
# return split_style
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def indents_processing(split_style: list) -> str:
|
def indents_processing(split_style: list) -> str:
|
||||||
@@ -130,16 +133,13 @@ class TagInlineStyleProcessor:
|
|||||||
inline_style, self.tag_inline_style)
|
inline_style, self.tag_inline_style)
|
||||||
inline_style = inline_style.replace(
|
inline_style = inline_style.replace(
|
||||||
"list-style-image", "list-style-type")
|
"list-style-image", "list-style-type")
|
||||||
|
|
||||||
# 2. Create list of styles from inline style
|
# 2. Create list of styles from inline style
|
||||||
# replace all spaces between "; & letter" to ";"
|
# replace all spaces between "; & letter" to ";"
|
||||||
style = re.sub(r"; *", ";", inline_style)
|
style = re.sub(r"; *", ";", inline_style)
|
||||||
# when we split style by ";", last element of the list is "" - None (remove it)
|
# when we split style by ";", last element of the list is "" - None (remove it)
|
||||||
split_inline_style: list = list(filter(None, style.split(";")))
|
split_inline_style: list = list(filter(None, style.split(";")))
|
||||||
|
|
||||||
# 3. Duplicate styles check - if the tag had duplicate styles
|
# 3. Duplicate styles check - if the tag had duplicate styles
|
||||||
split_inline_style = self.duplicate_styles_check(split_inline_style)
|
# split_inline_style = self.duplicate_styles_check(split_inline_style)
|
||||||
|
|
||||||
# 4. Processing indents
|
# 4. Processing indents
|
||||||
inline_style: str = self.indents_processing(split_inline_style)
|
inline_style: str = self.indents_processing(split_inline_style)
|
||||||
return inline_style
|
return inline_style
|
||||||
|
|||||||
Reference in New Issue
Block a user