mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Fix "unknown shortcode token" when calling shortcode within fenced code block
Fixes #10819
This commit is contained in:
parent
d55af2abf0
commit
e7148f335f
2 changed files with 38 additions and 1 deletions
|
@ -186,7 +186,7 @@ func (scp *ShortcodeWithPage) page() page.Page {
|
|||
const shortcodePlaceholderPrefix = "HAHAHUGOSHORTCODE"
|
||||
|
||||
func createShortcodePlaceholder(id string, ordinal int) string {
|
||||
return shortcodePlaceholderPrefix + "-" + id + strconv.Itoa(ordinal) + "-HBHB"
|
||||
return shortcodePlaceholderPrefix + id + strconv.Itoa(ordinal) + "HBHB"
|
||||
}
|
||||
|
||||
type shortcode struct {
|
||||
|
|
|
@ -1276,3 +1276,40 @@ Inner: {{ .Get 0 }}: {{ len .Inner }}
|
|||
b.Assert(err, qt.Not(qt.IsNil))
|
||||
b.Assert(err.Error(), qt.Contains, `p1.md:5:1": failed to extract shortcode: shortcode "sc" must be closed or self-closed`)
|
||||
}
|
||||
|
||||
// Issue 10819.
|
||||
func TestShortcodeInCodeFenceHyphen(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
disableKinds = ["home", "taxonomy", "term"]
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: "p1"
|
||||
---
|
||||
|
||||
§§§go
|
||||
{{< sc >}}
|
||||
§§§
|
||||
|
||||
Text.
|
||||
|
||||
-- layouts/shortcodes/sc.html --
|
||||
Hello.
|
||||
-- layouts/_default/single.html --
|
||||
{{ .Content }}
|
||||
`
|
||||
|
||||
b := NewIntegrationTestBuilder(
|
||||
IntegrationTestConfig{
|
||||
T: t,
|
||||
TxtarString: files,
|
||||
Running: true,
|
||||
Verbose: true,
|
||||
},
|
||||
).Build()
|
||||
|
||||
b.AssertFileContent("public/p1/index.html", "<span style=\"color:#a6e22e\">Hello.</span>")
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue