forked from LiveCarta/BookConverter
improve attributes mover
This commit is contained in:
@@ -27,8 +27,14 @@ class HtmlPresetsProcessor:
|
|||||||
kwargs["rule"]["tag_to_wrap"]))
|
kwargs["rule"]["tag_to_wrap"]))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _decompose_tag(**kwargs):
|
def set_attrs_to_parent(tag, parent_tag):
|
||||||
kwargs["tag"].parent.attrs.update(kwargs["tag"].attrs)
|
for key in tag.attrs:
|
||||||
|
if key not in parent_tag.attrs:
|
||||||
|
parent_tag.attrs[key] = tag.attrs[key]
|
||||||
|
|
||||||
|
def _decompose_tag(self, **kwargs):
|
||||||
|
if kwargs["tag"].parent:
|
||||||
|
self.set_attrs_to_parent(kwargs["tag"], kwargs["tag"].parent)
|
||||||
kwargs["tag"].decompose()
|
kwargs["tag"].decompose()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -111,9 +117,9 @@ class HtmlPresetsProcessor:
|
|||||||
elif attr:
|
elif attr:
|
||||||
del kwargs["tag"][attr]
|
del kwargs["tag"][attr]
|
||||||
|
|
||||||
@staticmethod
|
def _unwrap_tag(self, **kwargs):
|
||||||
def _unwrap_tag(**kwargs):
|
if kwargs["tag"].parent:
|
||||||
kwargs["tag"].parent.attrs.update(kwargs["tag"].attrs)
|
self.set_attrs_to_parent(kwargs["tag"], kwargs["tag"].parent)
|
||||||
kwargs["tag"].unwrap()
|
kwargs["tag"].unwrap()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user