diff --git a/markup/goldmark/render_hooks.go b/markup/goldmark/render_hooks.go index 12cf0045528..1e91f7ab131 100644 --- a/markup/goldmark/render_hooks.go +++ b/markup/goldmark/render_hooks.go @@ -499,10 +499,10 @@ func (r *hookedRenderer) renderHeading(w util.BufWriter, source []byte, node ast text := ctx.PopRenderedString() - // All ast.Heading nodes are guaranteed to have an attribute called "id" - // that is an array of bytes that encode a valid string. - anchori, _ := n.AttributeString("id") - anchor := anchori.([]byte) + var anchor []byte + if anchori, ok := n.AttributeString("id"); ok { + anchor, _ = anchori.([]byte) + } page, pageInner := render.GetPageAndPageInner(ctx) diff --git a/markup/goldmark/toc_integration_test.go b/markup/goldmark/toc_integration_test.go index 7ce2e86643f..814ae199b34 100644 --- a/markup/goldmark/toc_integration_test.go +++ b/markup/goldmark/toc_integration_test.go @@ -258,7 +258,29 @@ title: p7 (emoji) `) // emoji + b.AssertFileContent("public/p7/index.html", `