diff --git a/src/epub_postprocessor.py b/src/epub_postprocessor.py index e559f6e..d243300 100644 --- a/src/epub_postprocessor.py +++ b/src/epub_postprocessor.py @@ -313,7 +313,7 @@ class EpubPostprocessor: if anchor_tag.attrs['id'] not in self.internal_anchors: new_anchor_span = self._create_new_anchor_span(soup, new_id) anchor_tag.insert_before(new_anchor_span) - self.internal_anchors.add(anchor_tag.attrs['id']) + self.internal_anchors.add(new_id) del anchor_tag.attrs['id'] del internal_link_tag.attrs['href'] diff --git a/src/html_epub_preprocessor.py b/src/html_epub_preprocessor.py index d061df7..1e01690 100644 --- a/src/html_epub_preprocessor.py +++ b/src/html_epub_preprocessor.py @@ -377,7 +377,7 @@ def get_tags_between_chapter_marks(first_id, href, html_soup): return tags -def wrap_span_with_table(main_tag, old_tag): +def wrap_preformatted_span_with_table(main_tag, old_tag): table = main_tag.new_tag("table") table.attrs['border'] = '1px solid #ccc;' table.attrs['style'] = 'width:100%;' @@ -393,7 +393,7 @@ def wrap_span_with_table(main_tag, old_tag): return table -def wrap_block_with_table(main_tag, old_tag, color=None): +def wrap_block_tag_with_table(main_tag, old_tag, bg_color=None): table = main_tag.new_tag("table") table.attrs['border'] = '1px solid' table.attrs['align'] = 'center' @@ -402,8 +402,8 @@ def wrap_block_with_table(main_tag, old_tag, color=None): tr = main_tag.new_tag("tr") td = main_tag.new_tag("td") # td.attrs['border-radius'] = '8px' - if color: - td.attrs['bgcolor'] = color + if bg_color: + td.attrs['bgcolor'] = bg_color old_tag.wrap(td) td.wrap(tr) tr.wrap(tbody) @@ -426,7 +426,7 @@ def preprocess_block_tags(chapter_tag): color = '#DDDDDD' if block.attrs.get('class') == 'feature1' else None color = '#EEEEEE' if block.attrs.get('class') == 'feature2' else color - wrap_block_with_table(chapter_tag, block, color) + wrap_block_tag_with_table(chapter_tag, block, color) block.insert_after(BeautifulSoup(features='lxml').new_tag("br")) block.unwrap() @@ -464,7 +464,7 @@ def preprocess_pre_tags(chapter_tag): "font-size: 14px; white-space: nowrap;" pre.insert_before(new_tag) pre.extract() - table = wrap_span_with_table(chapter_tag, new_tag) + table = wrap_preformatted_span_with_table(chapter_tag, new_tag) p_for_br = chapter_tag.new_tag("p") p_for_br.string = "\xa0" table.insert_after(p_for_br)