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

@ -302,3 +302,51 @@ Attributes: {{ .Attributes }}|Options: {{ .Options }}|
testLanguage("bash", "Attributes: map[]|Options: map[style:monokai]|")
testLanguage("hugo", "Attributes: map[style:monokai]|Options: map[]|")
}
func TestPanics(t *testing.T) {
files := `
-- config.toml --
[markup]
[markup.goldmark]
[markup.goldmark.parser]
autoHeadingID = true
autoHeadingIDType = "github"
[markup.goldmark.parser.attribute]
block = true
title = true
-- content/p1.md --
---
title: "p1"
---
BLOCK
Common
-- layouts/_default/single.html --
{{ .Content }}
`
for _, test := range []struct {
name string
markdown string
}{
{"issue-9819", "asdf\n: {#myid}"},
} {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
b := hugolib.NewIntegrationTestBuilder(
hugolib.IntegrationTestConfig{
T: t,
TxtarString: strings.ReplaceAll(files, "BLOCK", test.markdown),
},
).Build()
b.AssertFileContent("public/p1/index.html", "Common")
})
}
}