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

Panic #453

Closed m8rge closed 5 months ago

m8rge commented 5 months ago

Please answer the following before submitting your issue:

  1. What version of goldmark are you using? : 1.7.1
  2. What version of Go are you using? : go1.22.1
  3. What operating system and processor architecture are you using? : apple M1, arm64
  4. What did you do? :
    goldmark.New(
        goldmark.WithExtensions(extension.Strikethrough),
        goldmark.WithRenderer(
            renderer.NewRenderer(renderer.WithNodeRenderers(
                util.Prioritized(newNotificationRenderer(), 500),
            )),
        ),
    )
    var buf strings.Builder
    if err := md.Convert([]byte(markdown), &buf); err != nil {
        return "", err
    }
    > [[api_infra_prod] [y] a](https://geeksocket.in/some-long-link-here)
    > [[api_infra_prod] [y] b](https://geeksocket.in/some-long-link-here)
    > [[api_infra_prod] [y] c](https://geeksocket.in/some-long-link-here)
    > [[api_infra_prod] [y] d](https://geeksocket.in/some-long-link-here)
  5. What did you expect to see? : valid output
  6. What did you see instead? : panic
    goroutine 234998 [running]:
    github.com/yuin/goldmark/renderer.(*renderer).Render.func2({0x3164c30, 0xc001e2cdd0}, 0x1)
    github.com/yuin/goldmark@v1.4.13/renderer/renderer.go:164 +0xd6
    github.com/yuin/goldmark/ast.walkHelper({0x3164c30, 0xc001e2cdd0}, 0xc005e79850)
    github.com/yuin/goldmark@v1.4.13/ast/ast.go:492 +0x2e
    github.com/yuin/goldmark/ast.walkHelper({0x3163910, 0xc0028fbd60}, 0xc005e79850)
    github.com/yuin/goldmark@v1.4.13/ast/ast.go:498 +0x85
    github.com/yuin/goldmark/ast.walkHelper({0x3164330, 0xc009670900}, 0xc005e79850)
    github.com/yuin/goldmark@v1.4.13/ast/ast.go:498 +0x85
    github.com/yuin/goldmark/ast.walkHelper({0x3163fd0, 0xc009670880}, 0xc005e79850)
    github.com/yuin/goldmark@v1.4.13/ast/ast.go:498 +0x85
    github.com/yuin/goldmark/ast.walkHelper({0x3164570, 0xc0097a4120}, 0xc005e79850)
    github.com/yuin/goldmark@v1.4.13/ast/ast.go:498 +0x85
    github.com/yuin/goldmark/ast.Walk(...)
    github.com/yuin/goldmark@v1.4.13/ast/ast.go:487
    github.com/yuin/goldmark/renderer.(*renderer).Render(0xc006c886e0, {0x31280c0, 0xc00592fb40}, {0xc0094c4c00, 0x5ac, 0x600}, {0x3164570, 0xc0097a4120})
    github.com/yuin/goldmark@v1.4.13/renderer/renderer.go:161 +0x230
    github.com/yuin/goldmark.(*markdown).Convert(0xc0094e8b00, {0xc0094c4c00, 0x5ac, 0x600}, {0x31280c0, 0xc00592fb40}, {0x0, 0x0, 0x0})
    github.com/yuin/goldmark@v1.4.13/markdown.go:117 +0x106
    ...
  7. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?: YES
yuin commented 5 months ago

Works as expected. This is a not runtime error, but coding error. You forgot add node kind for your extension.

m8rge commented 5 months ago

Hi yuin,

Thanks for reply!

In a fact, it doesn't matter register extension or not, panic is here. I can initiate parser like this: md := goldmark.New() and panic will be thrown.