extension which allowes to parse links with empty link text
parent
3e56bb68c8
commit
df0dfd23f8
|
@ -538,9 +538,12 @@ func link(p *Markdown, data []byte, offset int) (int, *Node) {
|
|||
unescapeText(&uLinkBuf, link)
|
||||
uLink = uLinkBuf.Bytes()
|
||||
}
|
||||
|
||||
// links need something to click on and somewhere to go
|
||||
if len(uLink) == 0 || (t == linkNormal && txtE <= 1) {
|
||||
// links need somewhere to go
|
||||
if len(uLink) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
// links usually need something to click on
|
||||
if t == linkNormal && txtE <= 1 && p.extensions&AllowLinksWithoutText == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -466,9 +466,20 @@ func TestInlineLink(t *testing.T) {
|
|||
|
||||
"[link](<../>)\n",
|
||||
"<p><a href=\"../\">link</a></p>\n",
|
||||
|
||||
"[](./dummy.md)\n",
|
||||
"<p>[](./dummy.md)</p>\n",
|
||||
}
|
||||
doLinkTestsInline(t, tests)
|
||||
|
||||
var testsAllowLinksWithoutText = []string{
|
||||
"[](./dummy.md)\n",
|
||||
"<p><a href=\"./dummy.md\"></a></p>\n",
|
||||
}
|
||||
doTestsInlineParam(t, testsAllowLinksWithoutText, TestParams{
|
||||
extensions: AllowLinksWithoutText,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestRelAttrLink(t *testing.T) {
|
||||
|
|
|
@ -47,6 +47,7 @@ const (
|
|||
AutoHeadingIDs // Create the heading ID from the text
|
||||
BackslashLineBreak // Translate trailing backslashes into line breaks
|
||||
DefinitionLists // Render definition lists
|
||||
AllowLinksWithoutText // Parse links without text, (e.g. [](./target.md)
|
||||
|
||||
CommonHTMLFlags HTMLFlags = UseXHTML | Smartypants |
|
||||
SmartypantsFractions | SmartypantsDashes | SmartypantsLatexDashes
|
||||
|
|
Loading…
Reference in New Issue