all repos — grayfriday @ 510be64de022c25096c6f476b7b7c240a8eca1a5

blackfriday fork with a few changes

Merge pull request #216 from russross/issue-194

Fix footnote following an exclamation point
Vytautas Ĺ altenis vytas@rtfb.lt
Wed, 04 Nov 2015 21:40:57 +0200
commit

510be64de022c25096c6f476b7b7c240a8eca1a5

parent

f21f06712134055e26c0f95aa39898fefc50f68e

2 files changed, 28 insertions(+), 5 deletions(-)

jump to
M inline.goinline.go

@@ -205,19 +205,26 @@ if p.insideLink && (offset > 0 && data[offset-1] == '[' || len(data)-1 > offset && data[offset+1] == '^') {

return 0 } - // [text] == regular link + var t linkType + switch { + // special case: ![^text] == deferred footnote (that follows something with + // an exclamation point) + case p.flags&EXTENSION_FOOTNOTES != 0 && len(data)-1 > offset && data[offset+1] == '^': + t = linkDeferredFootnote // ![alt] == image + case offset > 0 && data[offset-1] == '!': + t = linkImg // ^[text] == inline footnote // [^refId] == deferred footnote - var t linkType - if offset > 0 && data[offset-1] == '!' { - t = linkImg - } else if p.flags&EXTENSION_FOOTNOTES != 0 { + case p.flags&EXTENSION_FOOTNOTES != 0: if offset > 0 && data[offset-1] == '^' { t = linkInlineFootnote } else if len(data)-1 > offset && data[offset+1] == '^' { t = linkDeferredFootnote } + // [text] == regular link + default: + t = linkNormal } data = data[offset:]
M inline_test.goinline_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) {