parser no longer returns prematurely from empty footnote ref

This commit is contained in:
moshee 2013-07-08 22:34:12 +00:00
parent 4513607d62
commit 3ea84a5811
3 changed files with 15 additions and 8 deletions

View File

@ -481,15 +481,17 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
} }
var uLink []byte var uLink []byte
if len(link) > 0 { if t == linkNormal || t == linkImg {
var uLinkBuf bytes.Buffer if len(link) > 0 {
unescapeText(&uLinkBuf, link) var uLinkBuf bytes.Buffer
uLink = uLinkBuf.Bytes() unescapeText(&uLinkBuf, link)
} uLink = uLinkBuf.Bytes()
}
// links need something to click on and somewhere to go // links need something to click on and somewhere to go
if len(uLink) == 0 || (t == linkNormal && content.Len() == 0) { if len(uLink) == 0 || (t == linkNormal && content.Len() == 0) {
return 0 return 0
}
} }
// call the relevant rendering function // call the relevant rendering function

View File

@ -635,6 +635,9 @@ what happens here
</ol> </ol>
</div> </div>
`, `,
"empty footnote[^]\n\n[^]: fn text",
"<p>empty footnote<sup class=\"footnote-ref\" id=\"fnref:\"><a rel=\"footnote\" href=\"#fn:\">1</a></sup></p>\n<div class=\"footnotes\">\n\n<hr />\n\n<ol>\n<li id=\"fn:\">fn text\n</li>\n</ol>\n</div>\n",
} }
doTestsInlineParam(t, tests, EXTENSION_FOOTNOTES, 0) doTestsInlineParam(t, tests, EXTENSION_FOOTNOTES, 0)

View File

@ -508,7 +508,9 @@ func isReference(p *parser, data []byte, tabSize int) int {
// id matches are case-insensitive // id matches are case-insensitive
id := string(bytes.ToLower(data[idOffset:idEnd])) id := string(bytes.ToLower(data[idOffset:idEnd]))
p.refs[id] = ref p.refs[id] = ref
return lineEnd return lineEnd
} }