forked from LiveCarta/BookConverter
LAW-3262
- extra digits in footnotes from documents downloaded from livecarta
This commit is contained in:
15
src/book.py
15
src/book.py
@@ -564,7 +564,7 @@ class Book:
|
|||||||
footnotes = []
|
footnotes = []
|
||||||
for i, (anc_tag, cont_tag) in enumerate(zip(footnote_anchors, footnote_content)):
|
for i, (anc_tag, cont_tag) in enumerate(zip(footnote_anchors, footnote_content)):
|
||||||
assert anc_tag['name'] == cont_tag.find('a')['href'][1:], \
|
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 = BeautifulSoup(features='lxml').new_tag('sup')
|
||||||
new_tag['class'] = 'footnote-element'
|
new_tag['class'] = 'footnote-element'
|
||||||
@@ -573,7 +573,13 @@ class Book:
|
|||||||
new_tag.string = '*'
|
new_tag.string = '*'
|
||||||
anc_tag.replace_with(new_tag)
|
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()
|
cont_tag.a.decompose()
|
||||||
|
|
||||||
unicode_string = ''
|
unicode_string = ''
|
||||||
for child in cont_tag.children:
|
for child in cont_tag.children:
|
||||||
if type(child) is NavigableString:
|
if type(child) is NavigableString:
|
||||||
@@ -586,15 +592,8 @@ class Book:
|
|||||||
content = self._clean_footnote_content(unicode_string)
|
content = self._clean_footnote_content(unicode_string)
|
||||||
cont_tag.decompose()
|
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)
|
footnotes.append(content)
|
||||||
|
|
||||||
# i += 1
|
|
||||||
|
|
||||||
self.footnotes = footnotes
|
self.footnotes = footnotes
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user