- extra digits in footnotes from documents downloaded from livecarta
This commit is contained in:
shirshasa
2020-07-16 15:31:02 +03:00
parent ea14ed1634
commit 2c014ae36e

View File

@@ -564,7 +564,7 @@ class Book:
footnotes = []
for i, (anc_tag, cont_tag) in enumerate(zip(footnote_anchors, footnote_content)):
assert anc_tag['name'] == cont_tag.find('a')['href'][1:], \
'Some ting went wrong with footnotes after libra conversion'
'Something went wrong with footnotes after libra conversion'
new_tag = BeautifulSoup(features='lxml').new_tag('sup')
new_tag['class'] = 'footnote-element'
@@ -573,7 +573,13 @@ class Book:
new_tag.string = '*'
anc_tag.replace_with(new_tag)
# extra digits in footnotes from documents downloaded from livecarta
a_text = cont_tag.a.text
sup = cont_tag.find_all('p')[0].find('sup')
if sup and sup.text == a_text:
sup.decompose()
cont_tag.a.decompose()
unicode_string = ''
for child in cont_tag.children:
if type(child) is NavigableString:
@@ -586,15 +592,8 @@ class Book:
content = self._clean_footnote_content(unicode_string)
cont_tag.decompose()
# new_tag = BeautifulSoup(features="lxml").new_tag('div')
# new_tag['class'] = 'footnote-element'
# new_tag['data-id'] = f'"{i}"'
# new_tag['id'] = f'footnote-{i}'
# new_tag.string = content
# footnotes.append(str(new_tag))
footnotes.append(content)
# i += 1
self.footnotes = footnotes