mmarkdown / mmark

Mmark: a powerful markdown processor in Go geared towards the IETF
https://mmark.miek.nl
Other
480 stars 45 forks source link

Handle Parenthesis in links properly #98

Closed ghost closed 4 years ago

ghost commented 4 years ago

Using this file:

$ cat input.md
https://en.wikipedia.org/wiki/The_Master_(2012_film)

I get this result:

$ mmark -html input.md
<!DOCTYPE html>
<html>
<!-- ... -->
<body>
<p><a href="https://en.wikipedia.org/wiki/The_Master_(2012_film"
>https://en.wikipedia.org/wiki/The_Master_(2012_film</a>)</p>
</body>
</html>

Note that the final parenthesis is not included as part of the link. Other processors work as expected. For example GitHub parser:

https://en.wikipedia.org/wiki/The_Master_(2012_film)

ghost commented 4 years ago

Here is a workaround:

package main
import (
   "bytes"
   "github.com/yuin/goldmark"
   "github.com/yuin/goldmark/extension"
)
func main() {
   s1 := "https://en.wikipedia.org/wiki/The_Master_(2012_film)"
   o1 := goldmark.New(goldmark.WithExtensions(extension.Linkify))
   var b2 bytes.Buffer
   o1.Convert([]byte(s1), &b2)
   s2 := b2.String()
   print(s2)
}

https://github.com/yuin/goldmark

miekg commented 4 years ago

Enclose the link with < and >