aboutsummaryrefslogtreecommitdiffstats
path: root/mdx_footnotes.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2007-11-29 17:18:33 +0000
committerWaylan Limberg <waylan@gmail.com>2007-11-29 17:18:33 +0000
commit9f8372ece0b824e2038a7b728064ae454283db68 (patch)
tree8bbc4f1fc58636beb828f4ff2ad51745de413242 /mdx_footnotes.py
parent991ea1682465bd6f3e41e1d22fc541f41dd78c5e (diff)
downloadmarkdown-9f8372ece0b824e2038a7b728064ae454283db68.tar.gz
markdown-9f8372ece0b824e2038a7b728064ae454283db68.tar.bz2
markdown-9f8372ece0b824e2038a7b728064ae454283db68.zip
Footnotes that end in anyting but a <p> (list, blockquote, codeblock) now have
the backlink in a <p> which is appended to the end of the footnote. Fixes [1831600] Also fixed multiparagraph footnotes so that the first paragraph is actually wrapped in a <p> element. This results in one-liners also wrapped in <p> elements, but this is inline with PHP Markdown Extra's behavior. That means the test for `node.type == "text"` should never get a match, but I'm leaving it in for now. Also added some tests, although they are not properly included in a test directory for use with the testing framework. Seeing the framework currently ignores extensions, we'll worry about that later.
Diffstat (limited to 'mdx_footnotes.py')
-rw-r--r--mdx_footnotes.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mdx_footnotes.py b/mdx_footnotes.py
index 56ffd3a..b9641ce 100644
--- a/mdx_footnotes.py
+++ b/mdx_footnotes.py
@@ -116,7 +116,7 @@ class FootnoteExtension (markdown.Extension):
li = doc.createElement('li')
li.setAttribute('id', self.makeFootnoteId(i))
- self.md._processSection(li, self.footnotes[id].split("\n"))
+ self.md._processSection(li, self.footnotes[id].split("\n"), looseList=1)
#li.appendChild(doc.createTextNode(self.footnotes[id]))
@@ -130,8 +130,13 @@ class FootnoteExtension (markdown.Extension):
if li.childNodes :
node = li.childNodes[-1]
if node.type == "text" :
- node = li
- node.appendChild(backlink)
+ li.appendChild(backlink)
+ elif node.nodeName == "p":
+ node.appendChild(backlink)
+ else:
+ p = doc.createElement('p')
+ p.appendChild(backlink)
+ li.appendChild(p)
ol.appendChild(li)