diff options
-rw-r--r-- | mdx_footnotes.py | 11 | ||||
-rw-r--r-- | tests/footnote.html | 40 | ||||
-rw-r--r-- | tests/footnote.txt | 14 | ||||
-rw-r--r-- | tests/markdown-test/benchmark.dat.tmp | 38 | ||||
-rw-r--r-- | tests/misc/benchmark.dat.tmp | 95 |
5 files changed, 132 insertions, 66 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) diff --git a/tests/footnote.html b/tests/footnote.html new file mode 100644 index 0000000..6114176 --- /dev/null +++ b/tests/footnote.html @@ -0,0 +1,40 @@ +<p>This is the body with a footnote<sup id="fnr1-429656941"><a href="#fn1-429656941">1</a></sup> or two<sup id="fnr2-429656941"><a href="#fn2-429656941">2</a></sup> or more<sup id="fnr3-429656941"><a href="#fn3-429656941">3</a></sup> <sup id="fnr4-429656941"><a href="#fn4-429656941">4</a></sup>. +</p> + +<div class="footnote"><hr/><ol> + <li id="fn1-429656941"><p>Footnote that ends with a list: +</p> +<ul> + <li> + item 1 + </li> + + <li> + item 2 + </li> +</ul> +<p><a href="#fnr1-429656941" class="footnoteBackLink" title="Jump back to footnote 1 in the text">↩</a> +</p> + + </li> + + <li id="fn2-429656941"><blockquote><p>This footnote is a blockquote. +</p> +</blockquote><p><a href="#fnr2-429656941" class="footnoteBackLink" title="Jump back to footnote 1 in the text">↩</a> +</p> + + </li> + + <li id="fn3-429656941"><p>A simple oneliner.<a href="#fnr3-429656941" class="footnoteBackLink" title="Jump back to footnote 1 in the text">↩</a> +</p> + + </li> + + <li id="fn4-429656941"><p>A footnote with multiple paragraphs. +</p> +<p>Paragraph two.<a href="#fnr4-429656941" class="footnoteBackLink" title="Jump back to footnote 1 in the text">↩</a> +</p> + + </li> +</ol> +</div>
\ No newline at end of file diff --git a/tests/footnote.txt b/tests/footnote.txt new file mode 100644 index 0000000..07188d0 --- /dev/null +++ b/tests/footnote.txt @@ -0,0 +1,14 @@ +This is the body with a footnote[^1] or two[^2] or more[^3] [^4]. + +[^1]: Footnote that ends with a list: + + * item 1 + * item 2 + +[^2]: > This footnote is a blockquote. + +[^3]: A simple oneliner. + +[^4]: A footnote with multiple paragraphs. + + Paragraph two. diff --git a/tests/markdown-test/benchmark.dat.tmp b/tests/markdown-test/benchmark.dat.tmp index 4ab47cf..80b04cd 100644 --- a/tests/markdown-test/benchmark.dat.tmp +++ b/tests/markdown-test/benchmark.dat.tmp @@ -1,20 +1,20 @@ construction:0.000000:0.000000 -amps-and-angle-encoding:0.100000:0.000000 -auto-links:0.090000:0.000000 -backlash-escapes:0.350000:397312.000000 -blockquotes-with-dode-blocks:0.030000:0.000000 -hard-wrapped:0.030000:0.000000 -horizontal-rules:0.340000:-57344.000000 -inline-html-advanced:0.090000:0.000000 -inline-html-comments:0.120000:0.000000 -inline-html-simple:0.440000:0.000000 -links-inline:0.200000:0.000000 -links-reference:0.260000:0.000000 -literal-quotes:0.130000:0.000000 -markdown-documentation-basics:0.930000:991232.000000 -markdown-syntax:4.010000:2998272.000000 -nested-blockquotes:0.080000:0.000000 -ordered-and-unordered-list:0.530000:0.000000 -strong-and-em-together:0.110000:0.000000 -tabs:0.130000:0.000000 -tidyness:0.100000:0.000000 +amps-and-angle-encoding:0.030000:0.000000 +auto-links:0.030000:0.000000 +backlash-escapes:0.100000:131072.000000 +blockquotes-with-dode-blocks:0.010000:0.000000 +hard-wrapped:0.010000:0.000000 +horizontal-rules:0.080000:0.000000 +inline-html-advanced:0.030000:0.000000 +inline-html-comments:0.030000:0.000000 +inline-html-simple:0.100000:0.000000 +links-inline:0.050000:0.000000 +links-reference:0.070000:0.000000 +literal-quotes:0.030000:0.000000 +markdown-documentation-basics:0.340000:823296.000000 +markdown-syntax:1.620000:1568768.000000 +nested-blockquotes:0.050000:-110592.000000 +ordered-and-unordered-list:0.240000:-4096.000000 +strong-and-em-together:0.060000:0.000000 +tabs:0.060000:0.000000 +tidyness:0.060000:0.000000 diff --git a/tests/misc/benchmark.dat.tmp b/tests/misc/benchmark.dat.tmp index b18e8d1..fabdd97 100644 --- a/tests/misc/benchmark.dat.tmp +++ b/tests/misc/benchmark.dat.tmp @@ -1,47 +1,54 @@ -construction:0.000000:0.000000 -adjacent-headers:0.030000:0.000000 -amp-in-url:0.020000:0.000000 -ampersand:0.020000:0.000000 -arabic:0.170000:135168.000000 -attributes2:0.040000:0.000000 -bidi:0.460000:217088.000000 +construction:0.000000:-24576.000000 +adjacent-headers:0.010000:0.000000 +amp-in-url:0.000000:0.000000 +ampersand:0.010000:0.000000 +arabic:0.030000:0.000000 +attributes2:0.010000:0.000000 +bidi:0.090000:-57344.000000 +blank:0.000000:0.000000 blank-block-quote:0.010000:0.000000 -br:0.050000:0.000000 -comments:0.030000:0.000000 -div:0.050000:0.000000 -email:0.050000:0.000000 -funky-list:0.080000:0.000000 +blockquote-hr:0.020000:0.000000 +br:0.030000:0.000000 +bracket_re:1.580000:0.000000 +code-first-line:0.000000:0.000000 +comments:0.020000:0.000000 +div:0.030000:0.000000 +email:0.030000:0.000000 +funky-list:0.050000:0.000000 h1:0.030000:0.000000 -hash:0.050000:0.000000 -headers:0.060000:0.000000 +hash:0.030000:0.000000 +headers:0.030000:0.000000 hline:0.010000:0.000000 -html:0.070000:0.000000 -image:0.030000:0.000000 -image-2:0.050000:0.000000 -image_in_links:0.030000:0.000000 -inside_html:0.030000:0.000000 -japanese:0.120000:0.000000 -lists:0.090000:0.000000 -lists2:0.030000:0.000000 -lists3:0.030000:0.000000 -lists4:0.030000:0.000000 -lists5:0.050000:0.000000 -markup-inside-p:0.060000:0.000000 -more_comments:0.030000:0.000000 -multi-line-tags:0.040000:0.000000 -multi-test:0.110000:0.000000 -multiline-comments:0.060000:0.000000 -normalize:0.040000:0.000000 -numeric-entity:0.050000:0.000000 -php:0.060000:0.000000 -pre:0.050000:0.000000 -russian:0.180000:-49152.000000 -some-test:0.180000:-28672.000000 -span:0.100000:0.000000 -stronintags:0.090000:0.000000 -tabs-in-lists:0.140000:0.000000 -two-spaces:0.070000:0.000000 -uche:0.090000:0.000000 -underscores:0.100000:0.000000 -url_spaces:0.080000:0.000000 -utfbom:0.050000:0.000000 +html:0.040000:0.000000 +image:0.010000:0.000000 +image-2:0.020000:0.000000 +image_in_links:0.010000:0.000000 +inside_html:0.010000:0.000000 +japanese:0.050000:0.000000 +lazy-block-quote:0.010000:0.000000 +lists:0.040000:0.000000 +lists2:0.020000:0.000000 +lists3:0.020000:0.000000 +lists4:0.020000:0.000000 +lists5:0.030000:0.000000 +markup-inside-p:0.020000:0.000000 +mismatched-tags:0.020000:0.000000 +more_comments:0.020000:0.000000 +multi-line-tags:0.030000:0.000000 +multi-paragraph-block-quote:0.020000:0.000000 +multi-test:0.050000:0.000000 +multiline-comments:0.030000:0.000000 +normalize:0.020000:0.000000 +numeric-entity:0.020000:0.000000 +php:0.030000:0.000000 +pre:0.030000:0.000000 +russian:0.070000:0.000000 +some-test:0.080000:0.000000 +span:0.050000:0.000000 +stronintags:0.040000:0.000000 +tabs-in-lists:0.060000:0.000000 +two-spaces:0.060000:0.000000 +uche:0.040000:0.000000 +underscores:0.050000:0.000000 +url_spaces:0.030000:0.000000 +utfbom:0.030000:0.000000 |