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

Closing tag on a new line doesn't work #406

Closed Gusted closed 1 year ago

Gusted commented 1 year ago
  1. What version of goldmark are you using? : 1.5.4
  2. What version of Go are you using? : go1.20.6
  3. What operating system and processor architecture are you using? : linux/amd64
  4. What did you do? : Tried to render an <img> with the closing tag on a new line.
import (
    "bytes"
    "fmt"

    "github.com/yuin/goldmark"
    "github.com/yuin/goldmark/renderer/html"
)

func main() {
    md := goldmark.New(
        goldmark.WithRendererOptions(
            html.WithUnsafe(),
        ),
    )
    var buf bytes.Buffer
    if err := md.Convert([]byte("<img src=./.assets/logo.svg\n/>"), &buf); err != nil {
        panic(err)
    }
    fmt.Println(buf.String())
}
  1. What did you expect to see? :
    <p><img src=./.assets/logo.svg
    /></p>
  2. What did you see instead? :
    <p>&lt;img src=./.assets/logo.svg
    /&gt;</p>
  3. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?: https://spec.commonmark.org/dingus/?text=%3Cimg%20src%3D.%2F.assets%2Flogo.svg%0A%2F%3E