markup/goldmark: Fix panic on empty Markdown header

Fixes #13416
This commit is contained in:
Bjørn Erik Pedersen
2025-02-18 09:30:47 +01:00
parent f1e799c2e1
commit 494e88abf6
2 changed files with 26 additions and 4 deletions

View File

@@ -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)