markup/goldmark: Improve attributes vs options

Fixes #9571
This commit is contained in:
Bjørn Erik Pedersen
2022-02-26 17:24:10 +01:00
parent 928a896962
commit 579ff9b652
6 changed files with 41 additions and 19 deletions

View File

@@ -14,6 +14,7 @@
package codeblocks_test
import (
"strings"
"testing"
"github.com/gohugoio/hugo/hugolib"
@@ -176,7 +177,7 @@ Position: {{ .Position | safeHTML }}
}
// Issue 9571
func TestOptionsNonChroma(t *testing.T) {
func TestAttributesChroma(t *testing.T) {
t.Parallel()
files := `
@@ -188,23 +189,27 @@ title: "p1"
## Code
§§§bash {style=monokai}
§§§LANGUAGE {style=monokai}
echo "p1";
§§§
-- layouts/_default/single.html --
{{ .Content }}
-- layouts/_default/_markup/render-codeblock.html --
Style: {{ .Attributes }}|
Attributes: {{ .Attributes }}|Options: {{ .Options }}|
`
testLanguage := func(language, expect string) {
b := hugolib.NewIntegrationTestBuilder(
hugolib.IntegrationTestConfig{
T: t,
TxtarString: strings.ReplaceAll(files, "LANGUAGE", language),
},
).Build()
b := hugolib.NewIntegrationTestBuilder(
hugolib.IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b.AssertFileContent("public/p1/index.html", expect)
}
b.AssertFileContent("public/p1/index.html", "asdfadf")
testLanguage("bash", "Attributes: map[]|Options: map[style:monokai]|")
testLanguage("hugo", "Attributes: map[style:monokai]|Options: map[]|")
}