markup/goldmark: Fail on invalid Markdown attributes

This commit is contained in:
Bjørn Erik Pedersen 2023-03-14 12:45:09 +01:00
parent 0fbab7cbc5
commit b0b1b76dc9
5 changed files with 89 additions and 10 deletions

View file

@ -18,6 +18,8 @@ import (
"strings"
"testing"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/hugolib"
)
@ -384,3 +386,40 @@ Common
}
}
// Issue 10835
func TestAttributesValidation(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ["taxonomy", "term"]
-- content/p1.md --
---
title: "p1"
---
## Issue 10835
§§§bash { color=red dimensions=300x200 }
Hello, World!
§§§
-- layouts/index.html --
-- layouts/_default/single.html --
{{ .Content }}
-- layouts/_default/_markup/render-codeblock.html --
Attributes: {{ .Attributes }}|Type: {{ .Type }}|
`
b, err := hugolib.NewIntegrationTestBuilder(
hugolib.IntegrationTestConfig{
T: t,
TxtarString: files,
},
).BuildE()
b.Assert(err, qt.Not(qt.IsNil))
b.Assert(err.Error(), qt.Contains, "p1.md:7:9\": failed to parse Markdown attributes; you may need to quote the values")
}