Handle nested footnotes in separate passes.
Otherwise the nested one lands where the parent one already is, then doesn't get moved to the real destination.
This commit is contained in:
parent
5195b3a560
commit
d89394215b
1 changed files with 6 additions and 1 deletions
|
@ -115,8 +115,13 @@ def collect_footnotes(soup):
|
||||||
def inject_footnotes(soup):
|
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 contains_class(footnote_link.parent, 'gcufootnote_content'):
|
||||||
|
# In the case of nested footnotes, let's place the parent first
|
||||||
|
# and come back for this child on the next go around.
|
||||||
|
continue
|
||||||
if len(footnote_link.contents) != 1:
|
if len(footnote_link.contents) != 1:
|
||||||
print(footnote_link, 'is malformed. Should just be >[id<.')
|
print(footnote_link, 'is malformed. Should just be >[id]<.')
|
||||||
|
|
||||||
footnote_id = footnote_link.contents[0]
|
footnote_id = footnote_link.contents[0]
|
||||||
if not footnote_id.startswith('['):
|
if not footnote_id.startswith('['):
|
||||||
print(footnote_link, 'is malformed. Should start with [id].')
|
print(footnote_link, 'is malformed. Should start with [id].')
|
||||||
|
|
Loading…
Reference in a new issue