From 594c1e4fa032f801c58485a1d2800f6038430457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 13 Mar 2026 01:21:11 +0100 Subject: [PATCH] fix: guard FirstChild() nil in paragraph renderer A paragraph node with no children causes FirstChild() to return nil, making both the entering and leaving Kind() checks panic. Cache the result once and treat nil the same as a non-RawHTML child (emit

). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- renderer/paragraph.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/renderer/paragraph.go b/renderer/paragraph.go index 49c69a1..070e276 100644 --- a/renderer/paragraph.go +++ b/renderer/paragraph.go @@ -24,8 +24,9 @@ func (r *ConfluenceParagraphRenderer) RegisterFuncs(reg renderer.NodeRendererFun } func (r *ConfluenceParagraphRenderer) renderParagraph(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) { + firstChild := n.FirstChild() if entering { - if n.FirstChild().Kind() != ast.KindRawHTML { + if firstChild == nil || firstChild.Kind() != ast.KindRawHTML { if n.Attributes() != nil { _, _ = w.WriteString("") } _, _ = w.WriteString("\n")