From abb64b784e8fda8eb8628c32aa6c50dece37437a Mon Sep 17 00:00:00 2001 From: "mb @ ts" Date: Tue, 6 Mar 2018 12:01:42 +0100 Subject: [PATCH] added the ref number to the footnote --- complex_footnotes/simple_footnotes.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/complex_footnotes/simple_footnotes.py b/complex_footnotes/simple_footnotes.py index 5de48b7..4a13ae5 100644 --- a/complex_footnotes/simple_footnotes.py +++ b/complex_footnotes/simple_footnotes.py @@ -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] for article in sequence_gen(all_content): if u"[ref]" in article._content and u"[/ref]" in article._content: - content = article._content.replace(u"[ref]", u"").replace(u"[/ref]", - u"") + content = article._content.replace(u"[ref]", u"").replace(u"[/ref]", u"") parser = html5lib.HTMLParser(tree=html5lib.getTreeBuilder(u"dom")) dom = parser.parse(content) endnotes = [] @@ -57,25 +56,20 @@ def parse_for_footnotes(article_or_page_generator): endnotes.append((footnote, fnid, fnbackid)) number = dom.createElement(u"sup") number.setAttribute(u"id", fnbackid) - - numbera = dom.createElement(u"a") - numbera.setAttribute(u"href", u"#%s" % fnid) - numbera.setAttribute(u"class", u"simple-footnote") - numbera.appendChild(dom.createTextNode(six.text_type(count))) + number.setAttribute(u"class", u"simple-footnote") + number.appendChild(dom.createTextNode(six.text_type(count))) txt = getText(footnote, recursive=True).replace(u"\n", u" ") footnote_container = dom.createElement(u"span") footnote_container.setAttribute(u"class", u"simple-footnote-container") footnote_content = dom.createElement(u"span") + footnote_content.appendChild(dom.createTextNode('['+six.text_type(count)+'] ')) footnote_content.appendChild(footnote.firstChild) footnote_content.setAttribute(u"class", u"simple-footnote-content") footnote_container.appendChild(footnote_content) - print(footnote.firstChild) - - numbera.setAttribute(u"title", txt) - number.appendChild(footnote_container) - number.appendChild(numbera) + # print(footnote.firstChild) + number.appendChild(footnote_container) footnote.parentNode.insertBefore(number, footnote) footnote.parentNode.insertBefore(footnote_container, footnote) if endnotes: