forked from LiveCarta/BookConverter
Leave parent style only for decompose & unwrap
This commit is contained in:
@@ -28,6 +28,7 @@ class HtmlPresetsProcessor:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _decompose_tag(**kwargs):
|
def _decompose_tag(**kwargs):
|
||||||
|
kwargs["tag"].parent.attrs.update(kwargs["tag"].attrs)
|
||||||
kwargs["tag"].decompose()
|
kwargs["tag"].decompose()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -112,6 +113,7 @@ class HtmlPresetsProcessor:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _unwrap_tag(**kwargs):
|
def _unwrap_tag(**kwargs):
|
||||||
|
kwargs["tag"].parent.attrs.update(kwargs["tag"].attrs)
|
||||||
kwargs["tag"].unwrap()
|
kwargs["tag"].unwrap()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -153,7 +155,6 @@ class HtmlPresetsProcessor:
|
|||||||
for parent_tag in body_tag.select(condition_on_tag[1]):
|
for parent_tag in body_tag.select(condition_on_tag[1]):
|
||||||
for tag in parent_tag.find_all([re.compile(tag) for tag in tags]):
|
for tag in parent_tag.find_all([re.compile(tag) for tag in tags]):
|
||||||
# parent_tag != tag.parent
|
# parent_tag != tag.parent
|
||||||
tag.parent.attrs.update(tag.attrs)
|
|
||||||
action(body_tag=body_tag, tag=tag, rule=rule)
|
action(body_tag=body_tag, tag=tag, rule=rule)
|
||||||
elif condition_on_tag[0] == "child_tags":
|
elif condition_on_tag[0] == "child_tags":
|
||||||
for tag in body_tag.find_all([re.compile(tag) for tag in tags]):
|
for tag in body_tag.find_all([re.compile(tag) for tag in tags]):
|
||||||
|
|||||||
Reference in New Issue
Block a user