markup/goldmark: Fix attribute nilpointer

Fixes 9819
This commit is contained in:
Bjørn Erik Pedersen
2022-04-25 10:05:55 +02:00
parent 13ceef7599
commit d7b54a4c37
3 changed files with 49 additions and 19 deletions

View File

@@ -101,7 +101,7 @@ func (a *transformer) Transform(node *ast.Document, reader text.Reader, pc parse
// Attributes for fenced code blocks are handled in their own extension,
// but note that we currently only support code block attributes when
// CodeFences=true.
if node.PreviousSibling().Kind() != ast.KindFencedCodeBlock && !node.HasBlankPreviousLines() {
if node.PreviousSibling() != nil && node.PreviousSibling().Kind() != ast.KindFencedCodeBlock && !node.HasBlankPreviousLines() {
attributes = append(attributes, node)
return ast.WalkSkipChildren, nil
}