Leave parent style only for decompose & unwrap

This commit is contained in:
Kiryl
2022-09-19 17:30:08 +03:00
parent 979a4ab648
commit 0193cf3b7e

View File

@@ -28,6 +28,7 @@ class HtmlPresetsProcessor:
@staticmethod
def _decompose_tag(**kwargs):
kwargs["tag"].parent.attrs.update(kwargs["tag"].attrs)
kwargs["tag"].decompose()
@staticmethod
@@ -112,6 +113,7 @@ class HtmlPresetsProcessor:
@staticmethod
def _unwrap_tag(**kwargs):
kwargs["tag"].parent.attrs.update(kwargs["tag"].attrs)
kwargs["tag"].unwrap()
@staticmethod
@@ -153,7 +155,6 @@ class HtmlPresetsProcessor:
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]):
# parent_tag != tag.parent
tag.parent.attrs.update(tag.attrs)
action(body_tag=body_tag, tag=tag, rule=rule)
elif condition_on_tag[0] == "child_tags":
for tag in body_tag.find_all([re.compile(tag) for tag in tags]):