From 72651f0cf0cf9ed15c963058e5dc59d5de198064 Mon Sep 17 00:00:00 2001 From: shirshasa Date: Thu, 5 Aug 2021 11:12:20 +0300 Subject: [PATCH] epub converter: fix footnotes --- src/epub_postprocessor.py | 2 +- src/html_epub_preprocessor.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/epub_postprocessor.py b/src/epub_postprocessor.py index d243300..69c27aa 100644 --- a/src/epub_postprocessor.py +++ b/src/epub_postprocessor.py @@ -306,7 +306,7 @@ class EpubPostprocessor: f' While processing {internal_link_tag}') anchor_tag = anchor_tags[0] - assert anchor_tag.attrs['id'] == new_id + assert anchor_tag.attrs['id'] in [new_id, a_tag_id] # if anchor is found we could add placeholder for link creation on server side. internal_link_tag.attrs['placeholder'] = '{{tempStyleToAnchor-' + new_id + '}}' # create span to have cyclic links, link has 1 type of class, anchor another diff --git a/src/html_epub_preprocessor.py b/src/html_epub_preprocessor.py index 7e8ae9b..f073cdc 100644 --- a/src/html_epub_preprocessor.py +++ b/src/html_epub_preprocessor.py @@ -242,7 +242,8 @@ def preprocess_footnotes(source_html_tag: Tag, href2soup_html: dict = None, note content = footnote_tag.text # footnote_tag.decompose() footnotes.append(content) - new_footnotes_tags.append(footnote_tag.find(attrs={'role': 'doc-backlink'})) + footnote_tag = footnote_tag.find(attrs={'role': 'doc-backlink'}) or footnote_tag + new_footnotes_tags.append(footnote_tag) return footnotes, new_noterefs_tags, new_footnotes_tags