Merge pull request #216 from russross/issue-194

Fix footnote following an exclamation point
pull/217/head
Vytautas Šaltenis 2015-11-04 21:40:57 +02:00
commit 510be64de0
2 changed files with 28 additions and 5 deletions

View File

@ -205,19 +205,26 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
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:]

View File

@ -968,6 +968,22 @@ what happens here
</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>
`,
}