added the ref number to the footnote
This commit is contained in:
parent
bdd673841b
commit
abb64b784e
@ -35,8 +35,7 @@ def parse_for_footnotes(article_or_page_generator):
|
|||||||
all_content = [x for x in all_content if x is not None]
|
all_content = [x for x in all_content if x is not None]
|
||||||
for article in sequence_gen(all_content):
|
for article in sequence_gen(all_content):
|
||||||
if u"[ref]" in article._content and u"[/ref]" in article._content:
|
if u"[ref]" in article._content and u"[/ref]" in article._content:
|
||||||
content = article._content.replace(u"[ref]", u"<x-simple-footnote>").replace(u"[/ref]",
|
content = article._content.replace(u"[ref]", u"<x-simple-footnote>").replace(u"[/ref]", u"</x-simple-footnote>")
|
||||||
u"</x-simple-footnote>")
|
|
||||||
parser = html5lib.HTMLParser(tree=html5lib.getTreeBuilder(u"dom"))
|
parser = html5lib.HTMLParser(tree=html5lib.getTreeBuilder(u"dom"))
|
||||||
dom = parser.parse(content)
|
dom = parser.parse(content)
|
||||||
endnotes = []
|
endnotes = []
|
||||||
@ -57,25 +56,20 @@ def parse_for_footnotes(article_or_page_generator):
|
|||||||
endnotes.append((footnote, fnid, fnbackid))
|
endnotes.append((footnote, fnid, fnbackid))
|
||||||
number = dom.createElement(u"sup")
|
number = dom.createElement(u"sup")
|
||||||
number.setAttribute(u"id", fnbackid)
|
number.setAttribute(u"id", fnbackid)
|
||||||
|
number.setAttribute(u"class", u"simple-footnote")
|
||||||
numbera = dom.createElement(u"a")
|
number.appendChild(dom.createTextNode(six.text_type(count)))
|
||||||
numbera.setAttribute(u"href", u"#%s" % fnid)
|
|
||||||
numbera.setAttribute(u"class", u"simple-footnote")
|
|
||||||
numbera.appendChild(dom.createTextNode(six.text_type(count)))
|
|
||||||
txt = getText(footnote, recursive=True).replace(u"\n", u" ")
|
txt = getText(footnote, recursive=True).replace(u"\n", u" ")
|
||||||
|
|
||||||
footnote_container = dom.createElement(u"span")
|
footnote_container = dom.createElement(u"span")
|
||||||
footnote_container.setAttribute(u"class", u"simple-footnote-container")
|
footnote_container.setAttribute(u"class", u"simple-footnote-container")
|
||||||
footnote_content = dom.createElement(u"span")
|
footnote_content = dom.createElement(u"span")
|
||||||
|
footnote_content.appendChild(dom.createTextNode('['+six.text_type(count)+'] '))
|
||||||
footnote_content.appendChild(footnote.firstChild)
|
footnote_content.appendChild(footnote.firstChild)
|
||||||
footnote_content.setAttribute(u"class", u"simple-footnote-content")
|
footnote_content.setAttribute(u"class", u"simple-footnote-content")
|
||||||
footnote_container.appendChild(footnote_content)
|
footnote_container.appendChild(footnote_content)
|
||||||
print(footnote.firstChild)
|
# print(footnote.firstChild)
|
||||||
|
|
||||||
numbera.setAttribute(u"title", txt)
|
|
||||||
number.appendChild(footnote_container)
|
number.appendChild(footnote_container)
|
||||||
number.appendChild(numbera)
|
|
||||||
|
|
||||||
footnote.parentNode.insertBefore(number, footnote)
|
footnote.parentNode.insertBefore(number, footnote)
|
||||||
footnote.parentNode.insertBefore(footnote_container, footnote)
|
footnote.parentNode.insertBefore(footnote_container, footnote)
|
||||||
if endnotes:
|
if endnotes:
|
||||||
|
Loading…
Reference in New Issue
Block a user