yuin / goldmark

:trophy: A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.
MIT License
3.68k stars 255 forks source link

Links with newline characters in the title text fail to render correctly #94

Closed bhavin192 closed 4 years ago

bhavin192 commented 4 years ago
  1. What version of goldmark are you using? : Latest from master i.e. v1.1.21 or faaafa55b6dfe9b833032a9728ef82e8f34d0b15
  2. What version of Go are you using? : go version go1.13.5 linux/amd64
  3. What operating system and processor architecture are you using? : Fedora 31 on amd64
  4. What did you do? :
    
    package main

import ( "fmt" "github.com/yuin/goldmark" "bytes" )

func main() { source2 := [This link won't be rendered correctly](https://geeksocket.in/some-long-link-here "This is the place where everything breaks")

var buf bytes.Buffer
if err := goldmark.Convert([]byte(source2), &buf); err != nil {
    panic(err)
}
fmt.Println(buf.String())

}

5. What did you expect to see? :
The link should get rendered correctly with title attribute set.
6. What did you see instead? :
It get's rendered as
```html
<p>[This link won't be rendered
correctly](https://geeksocket.in/some-long-link-here &quot;This is the
place where everything breaks&quot;)</p>
  1. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?: Yes.

I tried going trough the source code and debug this issue, but I wasn't able to completely understand what all is happening in parseBlock function here https://github.com/yuin/goldmark/blob/master/parser/parser.go#L1106 For the link label it advances the next line segment correctly but for the title text it doesn't. Would like to send a fix if anyone can help me to understand why it's failing.