diff --git a/src/epub_converter/html_epub_preprocessor.py b/src/epub_converter/html_epub_preprocessor.py index 042b7b0..60cc91e 100644 --- a/src/epub_converter/html_epub_preprocessor.py +++ b/src/epub_converter/html_epub_preprocessor.py @@ -165,10 +165,14 @@ def _tags_to_correspond_livecarta_tag(chapter_tag): def _unwrap_tags(chapter_tag): """Function unwrap tags and move id to span""" - for tag in LiveCartaConfig.TAGS_TO_UNWRAP: - for s in chapter_tag.find_all(tag): - _add_span_to_save_ids_for_links(s, chapter_tag) - s.unwrap() + for tag_name in LiveCartaConfig.TAGS_TO_UNWRAP: + for tag in chapter_tag.select(tag_name): + # if tag is a subtag + if ">" in tag_name: + parent = tag.parent + tag.parent.attrs.update(tag.attrs) + _add_span_to_save_ids_for_links(tag, chapter_tag) + tag.unwrap() def _remove_headings_content(content_tag, title_of_chapter: str):