Renderer incompatible with goldmark 1.8 LinkReferenceDefinition node type #32

Open
opened 2026-04-21 10:14:52 +00:00 by ricellis · 0 comments
ricellis commented 2026-04-21 10:14:52 +00:00 (Migrated from github.com)

From https://github.com/yuin/goldmark/releases/tag/v1.8.0

Now link reference definition nodes are represented as a new node type.

The new ast.KindLinkReferenceDefinition type is not handled in github.com/teekennedy/goldmark-markdown@b2335388c7/renderer.go (L71) and this causes a panic from github.com/teekennedy/goldmark-markdown@b2335388c7/renderer.go (L105) when it encounters nodes of that type e.g.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10044628c]

goroutine 1 [running]:
github.com/teekennedy/goldmark-markdown.(*Renderer).Render.func2({0x1005a4048, 0x4072394d24b0}, 0x1)
	/go/pkg/mod/github.com/teekennedy/[email protected]/renderer.go:105 +0x4c
github.com/yuin/goldmark/ast.walkHelper({0x1005a4048, 0x4072394d24b0}, 0x4072395bfe28)
	/go/pkg/mod/github.com/yuin/[email protected]/ast/ast.go:543 +0x34
github.com/yuin/goldmark/ast.walkHelper({0x1005a3cb8, 0x40723949c0b0}, 0x4072395bfe28)
	/go/pkg/mod/github.com/yuin/[email protected]/ast/ast.go:549 +0x8c
github.com/yuin/goldmark/ast.Walk(...)
	/go/pkg/mod/github.com/yuin/[email protected]/ast/ast.go:538
github.com/teekennedy/goldmark-markdown.(*Renderer).Render(0x40723949a000, {0x1005a0d68, 0x4072394981e0}, {0x4072394bc280, 0x80, 0x80}, {0x1005a3cb8, 0x40723949c0b0})
	/go/pkg/mod/github.com/teekennedy/[email protected]/renderer.go:104 +0x1a8
github.com/yuin/goldmark.(*markdown).Convert(0x4072394269c0, {0x4072394bc280, 0x80, 0x80}, {0x1005a0d68, 0x4072394981e0}, {0x0, 0x0, 0x0})
	/go/pkg/mod/github.com/yuin/[email protected]/markdown.go:118 +0xac
main.main()
	/reproducer/main.go:23 +0xe4

Reproducer:

package main

import (
	"bytes"

	markdown "github.com/teekennedy/goldmark-markdown"
	"github.com/yuin/goldmark"
)

func main() {
	source := []byte(`# Test Document

This is a paragraph with a [link][ref].

[ref]: https://example.com "Example Site"

This is another paragraph.
`)

	renderer := markdown.NewRenderer()
	md := goldmark.New(goldmark.WithRenderer(renderer))

	md.Convert(source, &bytes.Buffer{})
}
From https://github.com/yuin/goldmark/releases/tag/v1.8.0 >Now link reference definition nodes are represented as a new node type. The new `ast.KindLinkReferenceDefinition` type is not handled in https://github.com/teekennedy/goldmark-markdown/blob/b2335388c79149357d9cbd80390df80d22328274/renderer.go#L71 and this causes a panic from https://github.com/teekennedy/goldmark-markdown/blob/b2335388c79149357d9cbd80390df80d22328274/renderer.go#L105 when it encounters nodes of that type e.g. ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10044628c] goroutine 1 [running]: github.com/teekennedy/goldmark-markdown.(*Renderer).Render.func2({0x1005a4048, 0x4072394d24b0}, 0x1) /go/pkg/mod/github.com/teekennedy/[email protected]/renderer.go:105 +0x4c github.com/yuin/goldmark/ast.walkHelper({0x1005a4048, 0x4072394d24b0}, 0x4072395bfe28) /go/pkg/mod/github.com/yuin/[email protected]/ast/ast.go:543 +0x34 github.com/yuin/goldmark/ast.walkHelper({0x1005a3cb8, 0x40723949c0b0}, 0x4072395bfe28) /go/pkg/mod/github.com/yuin/[email protected]/ast/ast.go:549 +0x8c github.com/yuin/goldmark/ast.Walk(...) /go/pkg/mod/github.com/yuin/[email protected]/ast/ast.go:538 github.com/teekennedy/goldmark-markdown.(*Renderer).Render(0x40723949a000, {0x1005a0d68, 0x4072394981e0}, {0x4072394bc280, 0x80, 0x80}, {0x1005a3cb8, 0x40723949c0b0}) /go/pkg/mod/github.com/teekennedy/[email protected]/renderer.go:104 +0x1a8 github.com/yuin/goldmark.(*markdown).Convert(0x4072394269c0, {0x4072394bc280, 0x80, 0x80}, {0x1005a0d68, 0x4072394981e0}, {0x0, 0x0, 0x0}) /go/pkg/mod/github.com/yuin/[email protected]/markdown.go:118 +0xac main.main() /reproducer/main.go:23 +0xe4 ``` Reproducer: ``` package main import ( "bytes" markdown "github.com/teekennedy/goldmark-markdown" "github.com/yuin/goldmark" ) func main() { source := []byte(`# Test Document This is a paragraph with a [link][ref]. [ref]: https://example.com "Example Site" This is another paragraph. `) renderer := markdown.NewRenderer() md := goldmark.New(goldmark.WithRenderer(renderer)) md.Convert(source, &bytes.Buffer{}) } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
golibs/goldmark-markdown#32
No description provided.