mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
a2670bf460
commit
812688fc2f
2 changed files with 38 additions and 0 deletions
|
@ -18,6 +18,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/gohugoio/hugo/helpers"
|
||||||
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
@ -517,6 +519,15 @@ Loop:
|
||||||
return sc, nil
|
return sc, nil
|
||||||
case currItem.IsText():
|
case currItem.IsText():
|
||||||
sc.inner = append(sc.inner, currItem.ValStr())
|
sc.inner = append(sc.inner, currItem.ValStr())
|
||||||
|
case currItem.Type == pageparser.TypeEmoji:
|
||||||
|
// TODO(bep) avoid the duplication of these "text cases", to prevent
|
||||||
|
// more of #6504 in the future.
|
||||||
|
val := currItem.ValStr()
|
||||||
|
if emoji := helpers.Emoji(val); emoji != nil {
|
||||||
|
sc.inner = append(sc.inner, string(emoji))
|
||||||
|
} else {
|
||||||
|
sc.inner = append(sc.inner, val)
|
||||||
|
}
|
||||||
case currItem.IsShortcodeName():
|
case currItem.IsShortcodeName():
|
||||||
|
|
||||||
sc.name = currItem.ValStr()
|
sc.name = currItem.ValStr()
|
||||||
|
|
|
@ -1171,6 +1171,33 @@ title: "Hugo Rocks!"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/gohugoio/hugo/issues/6504
|
||||||
|
func TestShortcodeEmoji(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
v := viper.New()
|
||||||
|
v.Set("enableEmoji", true)
|
||||||
|
|
||||||
|
builder := newTestSitesBuilder(t).WithViper(v)
|
||||||
|
|
||||||
|
builder.WithContent("page.md", `---
|
||||||
|
title: "Hugo Rocks!"
|
||||||
|
---
|
||||||
|
|
||||||
|
# doc
|
||||||
|
|
||||||
|
{{< event >}}10:30-11:00 My :smile: Event {{< /event >}}
|
||||||
|
|
||||||
|
|
||||||
|
`).WithTemplatesAdded(
|
||||||
|
"layouts/shortcodes/event.html", `<div>{{ "\u29BE" }} {{ .Inner }} </div>`)
|
||||||
|
|
||||||
|
builder.Build(BuildCfg{})
|
||||||
|
builder.AssertFileContent("public/page/index.html",
|
||||||
|
"⦾ 10:30-11:00 My 😄 Event",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func TestShortcodeTypedParams(t *testing.T) {
|
func TestShortcodeTypedParams(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
Loading…
Reference in a new issue