Split collection and injection of footnotes into two functions.

This commit is contained in:
Ethan Dalool 2019-12-29 13:04:42 -08:00
parent 4c5f416e2c
commit 5195b3a560

View file

@ -96,7 +96,7 @@ def remove_empty_elements(html):
return html return html
@soup_cleaner @soup_cleaner
def inject_footnotes(soup): def collect_footnotes(soup):
footnotes = soup.find_all('blockquote', {'class': 'gcufootnote_content'}) footnotes = soup.find_all('blockquote', {'class': 'gcufootnote_content'})
for footnote in footnotes: for footnote in footnotes:
try: try:
@ -111,6 +111,8 @@ def inject_footnotes(soup):
global_footnotes[footnote_id] = footnote global_footnotes[footnote_id] = footnote
@soup_cleaner
def inject_footnotes(soup):
footnote_links = soup.find_all('span', {'class': 'gcufootnote_link'}) footnote_links = soup.find_all('span', {'class': 'gcufootnote_link'})
for footnote_link in reversed(footnote_links): for footnote_link in reversed(footnote_links):
if len(footnote_link.contents) != 1: if len(footnote_link.contents) != 1: