LAW-6695 | Add span with id in _remove_headings_content

This commit is contained in:
Kibzik
2023-05-10 16:11:16 +03:00
parent 94c8687aa1
commit fae59d74eb

View File

@@ -116,11 +116,21 @@ class HtmlPresetsProcessor:
new_tag.string = "\xa0"
tag_to_be_removed.insert_before(new_tag)
if tag_to_be_removed.attrs.get("id"):
def has_child_with_id(tag):
"""
Check if any child tag has an 'id' attribute.
"""
for child in tag.children:
if child.has_attr('id'):
return child
return False
child_with_id = has_child_with_id(tag_to_be_removed)
if tag_to_be_removed.attrs.get("id") or child_with_id:
_insert_span_with_attrs_before_tag(chapter_tag=chapter_tag,
tag_to_be_removed=tag_to_be_removed,
id_=tag_to_be_removed.attrs["id"],
class_=tag_to_be_removed.attrs.get("class"))
id_=tag_to_be_removed.attrs["id"] if tag_to_be_removed.attrs.get("id") else child_with_id.attrs["id"],
class_=tag_to_be_removed.attrs["class"] if tag_to_be_removed.attrs.get("id") else child_with_id.attrs.get("class"))
def _process_tag_using_table(self, **kwargs):
def _wrap_tag_with_table(width: str = "100", border: str = "", bg_color: str = None) -> Tag: