From 0193cf3b7e31fdddf7a3c8373ee08f30748e7ad2 Mon Sep 17 00:00:00 2001 From: Kiryl Date: Mon, 19 Sep 2022 17:30:08 +0300 Subject: [PATCH] Leave parent style only for decompose & unwrap --- src/html_presets_processor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/html_presets_processor.py b/src/html_presets_processor.py index 30f7906..eeba3ca 100644 --- a/src/html_presets_processor.py +++ b/src/html_presets_processor.py @@ -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]):