From 5195b3a5603d9d14b1e58d8b7dfa15e73af7066b Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 29 Dec 2019 13:04:42 -0800 Subject: [PATCH] Split collection and injection of footnotes into two functions. --- cleanerupper/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cleanerupper/plugin.py b/cleanerupper/plugin.py index d4cb07a..1a765a4 100644 --- a/cleanerupper/plugin.py +++ b/cleanerupper/plugin.py @@ -96,7 +96,7 @@ def remove_empty_elements(html): return html @soup_cleaner -def inject_footnotes(soup): +def collect_footnotes(soup): footnotes = soup.find_all('blockquote', {'class': 'gcufootnote_content'}) for footnote in footnotes: try: @@ -111,6 +111,8 @@ def inject_footnotes(soup): global_footnotes[footnote_id] = footnote +@soup_cleaner +def inject_footnotes(soup): footnote_links = soup.find_all('span', {'class': 'gcufootnote_link'}) for footnote_link in reversed(footnote_links): if len(footnote_link.contents) != 1: