Open ccampbell opened 8 years ago
Upon reading this I was certain this is a duplicate, but after carefully reviewing the list of issues twice, I can't find the other report, weird.... Wherever the original is hiding, thanks for reporting!
I tried to find another ticket first, but I couldn't find one. I did find this in the tests:
Looks like there are tests for when you format the link yourself, but not the autolink part
@rtfb, are these not it?
There's also this one that's vaguely related:
Yup, they are. Didn't expect them to be fixed, so only looked among the open ones.
@rtfb those tickets are for when you manually put in the markdown for the URL. That is fixed and working correctly.
This ticket is for if you put the URL in your markdown without wrapping it in []()
For anyone reading this who is desperate for a workaround, you can use goquery to "fix" the links.
doc.Find("a[href*='(']:not([href$=')'])").Each(func(_ int, sel *goquery.Selection) {
if len(sel.Nodes) == 0 {
return
}
sibling := sel.Nodes[0].NextSibling
if sibling == nil || sibling.Type != html.TextNode || !strings.HasPrefix(sibling.Data, ")") {
return
}
href, _ := sel.Attr("href")
fixed := href + ")"
sel.SetAttr("href", fixed)
if sel.Text() == href {
sel.SetText(fixed)
sibling.Data = strings.TrimPrefix(sibling.Data, ")")
}
})
For example if you have some markdown text with:
The final markup ends up being
Notice the final closing parenthesis is not matched