Merge pull request #215 from russross/issue-193 Fix nested footnotes
Vytautas Ĺ altenis vytas@rtfb.lt
Wed, 04 Nov 2015 21:37:52 +0200
2 files changed,
35 insertions(+),
1 deletions(-)
M
inline_test.go
→
inline_test.go
@@ -1000,6 +1000,33 @@
doTestsInlineParam(t, tests, Options{Extensions: EXTENSION_FOOTNOTES}, HTML_FOOTNOTE_RETURN_LINKS, params) } +func TestNestedFootnotes(t *testing.T) { + var tests = []string{ + `Paragraph.[^fn1] + +[^fn1]: + Asterisk[^fn2] + +[^fn2]: + Obelisk`, + `<p>Paragraph.<sup class="footnote-ref" id="fnref:fn1"><a rel="footnote" href="#fn:fn1">1</a></sup></p> +<div class="footnotes"> + +<hr /> + +<ol> +<li id="fn:fn1">Asterisk<sup class="footnote-ref" id="fnref:fn2"><a rel="footnote" href="#fn:fn2">2</a></sup> +</li> +<li id="fn:fn2">Obelisk +</li> +</ol> +</div> +`, + } + doTestsInlineParam(t, tests, Options{Extensions: EXTENSION_FOOTNOTES}, 0, + HtmlRendererParameters{}) +} + func TestInlineComments(t *testing.T) { var tests = []string{ "Hello <!-- there ->\n",
M
markdown.go
→
markdown.go
@@ -20,6 +20,7 @@ package blackfriday
import ( "bytes" + "fmt" "strings" "unicode/utf8" )@@ -452,7 +453,8 @@
if p.flags&EXTENSION_FOOTNOTES != 0 && len(p.notes) > 0 { p.r.Footnotes(&output, func() bool { flags := LIST_ITEM_BEGINNING_OF_LIST - for _, ref := range p.notes { + for i := 0; i < len(p.notes); i += 1 { + ref := p.notes[i] var buf bytes.Buffer if ref.hasBlock { flags |= LIST_ITEM_CONTAINS_BLOCK@@ -513,6 +515,11 @@ title []byte
noteId int // 0 if not a footnote ref hasBlock bool text []byte +} + +func (r *reference) String() string { + return fmt.Sprintf("{link: %q, title: %q, text: %q, noteId: %d, hasBlock: %v}", + r.link, r.title, r.text, r.noteId, r.hasBlock) } // Check whether or not data starts with a reference link.