forked from LiveCarta/BookConverter
Fix if there is no parent tags to move label
This commit is contained in:
@@ -279,8 +279,9 @@ class EpubConverter:
|
|||||||
for html_href, soup in self.html_href2html_body_soup.items():
|
for html_href, soup in self.html_href2html_body_soup.items():
|
||||||
for i in self.html_href2subchapters_ids[html_href]:
|
for i in self.html_href2subchapters_ids[html_href]:
|
||||||
tag = soup.find(id=i)
|
tag = soup.find(id=i)
|
||||||
# in order not to lose tags in verification of same level of chapter
|
# in order not to lose tags in verification of same level in chapter
|
||||||
parent_tag = tag.find_parents(['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5'])[-1]
|
parent_tags = tag.find_parents(['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5'])
|
||||||
|
parent_tag = parent_tags[-1] if parent_tags else tag
|
||||||
tmp_tag = soup.new_tag("lc_tmp")
|
tmp_tag = soup.new_tag("lc_tmp")
|
||||||
tmp_tag.attrs["class"] = "converter-chapter-mark"
|
tmp_tag.attrs["class"] = "converter-chapter-mark"
|
||||||
tmp_tag.attrs["id"] = i
|
tmp_tag.attrs["id"] = i
|
||||||
|
|||||||
Reference in New Issue
Block a user