From 3ea84a5811efb21f6663ea315a3dbe3425c6831e Mon Sep 17 00:00:00 2001 From: moshee Date: Mon, 8 Jul 2013 22:34:12 +0000 Subject: [PATCH] parser no longer returns prematurely from empty footnote ref --- inline.go | 18 ++++++++++-------- inline_test.go | 3 +++ markdown.go | 2 ++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/inline.go b/inline.go index ca7c6b1..ab58685 100644 --- a/inline.go +++ b/inline.go @@ -481,15 +481,17 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int { } var uLink []byte - if len(link) > 0 { - var uLinkBuf bytes.Buffer - unescapeText(&uLinkBuf, link) - uLink = uLinkBuf.Bytes() - } + if t == linkNormal || t == linkImg { + if len(link) > 0 { + var uLinkBuf bytes.Buffer + unescapeText(&uLinkBuf, link) + uLink = uLinkBuf.Bytes() + } - // links need something to click on and somewhere to go - if len(uLink) == 0 || (t == linkNormal && content.Len() == 0) { - return 0 + // links need something to click on and somewhere to go + if len(uLink) == 0 || (t == linkNormal && content.Len() == 0) { + return 0 + } } // call the relevant rendering function diff --git a/inline_test.go b/inline_test.go index 584a584..f621529 100644 --- a/inline_test.go +++ b/inline_test.go @@ -635,6 +635,9 @@ what happens here `, + + "empty footnote[^]\n\n[^]: fn text", + "

empty footnote1

\n
\n\n
\n\n
    \n
  1. fn text\n
  2. \n
\n
\n", } doTestsInlineParam(t, tests, EXTENSION_FOOTNOTES, 0) diff --git a/markdown.go b/markdown.go index b0bf55e..8688683 100644 --- a/markdown.go +++ b/markdown.go @@ -508,7 +508,9 @@ func isReference(p *parser, data []byte, tabSize int) int { // id matches are case-insensitive id := string(bytes.ToLower(data[idOffset:idEnd])) + p.refs[id] = ref + return lineEnd }