fix footnote creating

- only p tags were processed before
This commit is contained in:
shirshasa
2020-07-13 17:57:37 +03:00
parent f77d90a89c
commit 2abff5f476

View File

@@ -10,7 +10,7 @@ from threading import Event
from copy import copy from copy import copy
from shutil import copyfile from shutil import copyfile
from bs4 import BeautifulSoup from bs4 import BeautifulSoup, NavigableString
class Book: class Book:
@@ -572,7 +572,16 @@ class Book:
anc_tag.replace_with(new_tag) anc_tag.replace_with(new_tag)
cont_tag.a.decompose() cont_tag.a.decompose()
content = self._clean_footnote_content(cont_tag.p.decode_contents()) unicode_string = ''
for child in cont_tag.children:
if type(child) is NavigableString:
continue
if child.name == 'blockquote':
unicode_string += str(child)
else:
unicode_string += child.decode_contents()
content = self._clean_footnote_content(unicode_string)
cont_tag.decompose() cont_tag.decompose()
# new_tag = BeautifulSoup(features="lxml").new_tag('div') # new_tag = BeautifulSoup(features="lxml").new_tag('div')
@@ -837,10 +846,10 @@ class Book:
self.content = self.body_tag.find_all(recursive=False) self.content = self.body_tag.find_all(recursive=False)
self._process_lists()
# delete text before table of content if exists # delete text before table of content if exists
self.delete_content_before_toc() self.delete_content_before_toc()
self._process_lists()
except Exception as exc: except Exception as exc:
self.log('Error has occurred while processing html.', logging.ERROR) self.log('Error has occurred while processing html.', logging.ERROR)
self.log_error_to_main_log() self.log_error_to_main_log()