Merge pull request #216 from russross/issue-194
Fix footnote following an exclamation point
This commit is contained in:
commit
510be64de0
17
inline.go
17
inline.go
|
@ -205,19 +205,26 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
|
||||||
return 0
|
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
|
// ![alt] == image
|
||||||
|
case offset > 0 && data[offset-1] == '!':
|
||||||
|
t = linkImg
|
||||||
// ^[text] == inline footnote
|
// ^[text] == inline footnote
|
||||||
// [^refId] == deferred footnote
|
// [^refId] == deferred footnote
|
||||||
var t linkType
|
case p.flags&EXTENSION_FOOTNOTES != 0:
|
||||||
if offset > 0 && data[offset-1] == '!' {
|
|
||||||
t = linkImg
|
|
||||||
} else if p.flags&EXTENSION_FOOTNOTES != 0 {
|
|
||||||
if offset > 0 && data[offset-1] == '^' {
|
if offset > 0 && data[offset-1] == '^' {
|
||||||
t = linkInlineFootnote
|
t = linkInlineFootnote
|
||||||
} else if len(data)-1 > offset && data[offset+1] == '^' {
|
} else if len(data)-1 > offset && data[offset+1] == '^' {
|
||||||
t = linkDeferredFootnote
|
t = linkDeferredFootnote
|
||||||
}
|
}
|
||||||
|
// [text] == regular link
|
||||||
|
default:
|
||||||
|
t = linkNormal
|
||||||
}
|
}
|
||||||
|
|
||||||
data = data[offset:]
|
data = data[offset:]
|
||||||
|
|
|
@ -968,6 +968,22 @@ what happens here
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</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>
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue