From 24c65d57b5ed7fded3a4f6d042db07b97aa08027 Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Tue, 19 May 2015 16:22:45 +0300 Subject: [PATCH 1/5] Update footnotes.py Append backlink to the last and lowermost element in footnote --- markdown/extensions/footnotes.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index d8caae27c..fc29e66b8 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -153,14 +153,17 @@ def makeFootnotesDiv(self, root): ) backlink.text = FN_BACKLINK_TEXT - if li.getchildren(): - node = li[-1] - if node.tag == "p": - node.text = node.text + NBSP_PLACEHOLDER - node.append(backlink) - else: - p = etree.SubElement(li, "p") - p.append(backlink) + #appending backlink to the lowermost element + #of last tag in footnote + elem = li + while True: + children = elem.getchildren(); + if len(children) == 0: + break; + elem = children[-1] + + elem.text = node.text + NBSP_PLACEHOLDER + elem.append(backlink) return div From 5f82073d976b9518eedc251a3907602fd152c6bb Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Wed, 20 May 2015 23:11:38 +0300 Subject: [PATCH 2/5] Update footnotes.py --- markdown/extensions/footnotes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index fc29e66b8..80d09d8da 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -162,7 +162,7 @@ def makeFootnotesDiv(self, root): break; elem = children[-1] - elem.text = node.text + NBSP_PLACEHOLDER + elem.text += NBSP_PLACEHOLDER elem.append(backlink) return div From 3a4173c4e6ce578e3e9ed2ff97436875336effb3 Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Thu, 21 May 2015 18:02:39 +0300 Subject: [PATCH 3/5] Update footnote.html --- tests/extensions/extra/footnote.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/extensions/extra/footnote.html b/tests/extensions/extra/footnote.html index e5b41a729..08383c975 100644 --- a/tests/extensions/extra/footnote.html +++ b/tests/extensions/extra/footnote.html @@ -7,15 +7,13 @@

Footnote that ends with a list:

  • item 1
  • -
  • item 2
  • +
  • item 2
-

  • -

    This footnote is a blockquote.

    +

    This footnote is a blockquote.

    -

  • A simple oneliner. 

    @@ -26,8 +24,8 @@
  • First line of first paragraph. -Second line of first paragraph is not intended. +Second line of first paragraph is not indented. Nor is third... 

  • - \ No newline at end of file + From ee061f337ce9266a43a9d4e00df10a63b2e0a9a6 Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Thu, 21 May 2015 18:02:55 +0300 Subject: [PATCH 4/5] Update footnote.txt --- tests/extensions/extra/footnote.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/extensions/extra/footnote.txt b/tests/extensions/extra/footnote.txt index c5c1c92b4..77bd8b46e 100644 --- a/tests/extensions/extra/footnote.txt +++ b/tests/extensions/extra/footnote.txt @@ -16,5 +16,5 @@ Also a reference that does not exist[^6]. Paragraph two. [^5]: First line of first paragraph. -Second line of first paragraph is not intended. +Second line of first paragraph is not indented. Nor is third... From 8e195b7d3d95a282cc50946f7b63f6cc1d306920 Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Thu, 21 May 2015 18:32:22 +0300 Subject: [PATCH 5/5] Update footnote.html Restore nbsp; --- tests/extensions/extra/footnote.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/extensions/extra/footnote.html b/tests/extensions/extra/footnote.html index 08383c975..dfe6dfb5a 100644 --- a/tests/extensions/extra/footnote.html +++ b/tests/extensions/extra/footnote.html @@ -7,12 +7,12 @@

    Footnote that ends with a list:

    • item 1
    • -
    • item 2
    • +
    • item 2 
  • -

    This footnote is a blockquote.

    +

    This footnote is a blockquote.