diff --git a/inline.go b/inline.go index 455f8fe..0e7cb86 100644 --- a/inline.go +++ b/inline.go @@ -181,7 +181,7 @@ const ( // '[': parse a link or an image or a footnote func link(p *parser, out *bytes.Buffer, data []byte, offset int) int { // no links allowed inside regular links, footnote, and deferred footnotes - if p.insideLink && (data[offset-1] == '[' || data[offset+1] == '^') { + if p.insideLink && (offset > 0 && data[offset-1] == '[' || len(data)-1 > offset && data[offset+1] == '^') { return 0 } diff --git a/inline_test.go b/inline_test.go index f7bc336..b7a1688 100644 --- a/inline_test.go +++ b/inline_test.go @@ -410,6 +410,9 @@ func TestInlineLink(t *testing.T) { "[link](/url/&query)\n", "
\n", + + "[[t]](/t)\n", + "\n", } doTestsInline(t, tests) }