summaryrefslogtreecommitdiffstats
path: root/markup/goldmark/render_hooks.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-02-18 09:30:47 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-02-18 11:12:39 +0100
commit494e88abf6007c48e51e5e065936ba88b3b75a87 (patch)
tree94b0ef6170344ff724d86e92631c4c6ad4f7bae8 /markup/goldmark/render_hooks.go
parentf1e799c2e174f5d78cec46a678490b5872afcb2c (diff)
downloadhugo-494e88abf6007c48e51e5e065936ba88b3b75a87.tar.gz
hugo-494e88abf6007c48e51e5e065936ba88b3b75a87.zip
markup/goldmark: Fix panic on empty Markdown header
Fixes #13416
Diffstat (limited to 'markup/goldmark/render_hooks.go')
-rw-r--r--markup/goldmark/render_hooks.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/markup/goldmark/render_hooks.go b/markup/goldmark/render_hooks.go
index 12cf00455..1e91f7ab1 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)