Throw an error when shortcode is expected to be closed

Fixes #10675
This commit is contained in:
Bjørn Erik Pedersen
2023-02-23 08:08:17 +01:00
parent 0dbeac80cd
commit 7d78a498e1
2 changed files with 47 additions and 1 deletions

View File

@@ -1241,3 +1241,38 @@ InnerDeindent: closing-no-newline: 0
`)
}
// Issue 10675.
func TestShortcodeErrorWhenItShouldBeClosed(t *testing.T) {
t.Parallel()
files := `
-- config.toml --
disableKinds = ["home", "taxonomy", "term"]
-- content/p1.md --
---
title: "p1"
---
{{< sc >}}
Text.
-- layouts/shortcodes/sc.html --
Inner: {{ .Get 0 }}: {{ len .Inner }}
-- layouts/_default/single.html --
{{ .Content }}
`
b, err := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
Running: true,
Verbose: true,
},
).BuildE()
b.Assert(err, qt.Not(qt.IsNil))
b.Assert(err.Error(), qt.Contains, `p1.md:5:1": failed to extract shortcode: unclosed shortcode "sc"`)
}