Fix footnote following an exclamation point Link parser interpreted the sequence "![^foo]" as an image, but if footnote extension is enabled, it's quite clear that it should be interpreted as a footnote following something with an exclamation point at the end. Closes #194.
Vytautas Ĺ altenis vytas@rtfb.lt
Tue, 03 Nov 2015 20:52:36 +0200
2 files changed,
21 insertions(+),
0 deletions(-)
M
inline.go
→
inline.go
@@ -212,6 +212,11 @@ // [^refId] == deferred footnote
var t linkType if offset > 0 && data[offset-1] == '!' { t = linkImg + // if footnotes extension is ON and we've seen "![^", then it's not an + // image, it's a deferred footnote: + if p.flags&EXTENSION_FOOTNOTES != 0 && len(data)-1 > offset && data[offset+1] == '^' { + t = linkDeferredFootnote + } } else if p.flags&EXTENSION_FOOTNOTES != 0 { if offset > 0 && data[offset-1] == '^' { t = linkInlineFootnote
M
inline_test.go
→
inline_test.go
@@ -969,6 +969,22 @@ </li>
</ol> </div> `, + + `This is exciting![^fn1] + +[^fn1]: Fine print +`, + `<p>This is exciting!<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">Fine print +</li> +</ol> +</div> +`, } func TestFootnotes(t *testing.T) {