diff --git a/src/epub_postprocessor.py b/src/epub_postprocessor.py index da7d9e7..b57bddb 100644 --- a/src/epub_postprocessor.py +++ b/src/epub_postprocessor.py @@ -245,15 +245,15 @@ class EpubPostprocessor: new_anchor_already_created = soup.find_all('span', attrs={'class': 'link-anchor', 'id': anchor_tag.attrs['id']}) - if not new_anchor_already_created: + if anchor_tag.attrs['id'] not in self.internal_anchors: new_anchor_span = soup.new_tag("span") new_anchor_span.attrs['id'] = anchor_tag.attrs['id'] new_anchor_span.attrs['class'] = 'link-anchor' - anchor_tag.insert(0, new_anchor_span) + new_anchor_span.string = "\xa0" + anchor_tag.insert_before(new_anchor_span) + self.internal_anchors.add(anchor_tag.attrs['id']) del anchor_tag.attrs['id'] - self.internal_anchors.add(new_anchor_span) - - del internal_link_tag.attrs['href'] + del internal_link_tag.attrs['href'] else: internal_link_tag.attrs['converter-mark'] = 'bad-link' diff --git a/src/html_epub_preprocessor.py b/src/html_epub_preprocessor.py index d226fe5..bc2fde2 100644 --- a/src/html_epub_preprocessor.py +++ b/src/html_epub_preprocessor.py @@ -53,6 +53,7 @@ def update_src_links_in_images(body_tag: Tag, new_folder = save_image_locally(path_to_img_from_root, img_content, 'book_id') img.attrs['src'] = str(new_folder) + img.attrs['style'] = 'align: center;' return path2aws_path