mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-29 23:20:49 +03:00
parent
69a56420ae
commit
33c738116c
3 changed files with 19 additions and 5 deletions
|
@ -53,7 +53,7 @@ func (p pageContent) contentToRender(renderedShortcodes map[string]string) []byt
|
||||||
case pageContentReplacement:
|
case pageContentReplacement:
|
||||||
c = append(c, v.val...)
|
c = append(c, v.val...)
|
||||||
case *shortcode:
|
case *shortcode:
|
||||||
if v.doMarkup || !p.renderable {
|
if !p.renderable || !v.insertPlaceholder() {
|
||||||
// Insert the rendered shortcode.
|
// Insert the rendered shortcode.
|
||||||
renderedShortcode, found := renderedShortcodes[v.placeholder]
|
renderedShortcode, found := renderedShortcodes[v.placeholder]
|
||||||
if !found {
|
if !found {
|
||||||
|
@ -127,9 +127,9 @@ func (p *pageContentMap) AddReplacement(val []byte, source pageparser.Item) {
|
||||||
|
|
||||||
func (p *pageContentMap) AddShortcode(s *shortcode) {
|
func (p *pageContentMap) AddShortcode(s *shortcode) {
|
||||||
p.items = append(p.items, s)
|
p.items = append(p.items, s)
|
||||||
if s.doMarkup {
|
if s.insertPlaceholder() {
|
||||||
p.hasMarkdownShortcode = true
|
|
||||||
} else {
|
|
||||||
p.hasNonMarkdownShortcode = true
|
p.hasNonMarkdownShortcode = true
|
||||||
|
} else {
|
||||||
|
p.hasMarkdownShortcode = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,6 +201,10 @@ type shortcode struct {
|
||||||
length int // the length in bytes in the source file
|
length int // the length in bytes in the source file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s shortcode) insertPlaceholder() bool {
|
||||||
|
return !s.doMarkup || s.info.Config.Version == 1
|
||||||
|
}
|
||||||
|
|
||||||
func (s shortcode) innerString() string {
|
func (s shortcode) innerString() string {
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
|
|
||||||
|
|
|
@ -531,6 +531,13 @@ tags:
|
||||||
**Tags:** {{< tags >}}`,
|
**Tags:** {{< tags >}}`,
|
||||||
filepath.FromSlash("public/sect/doc11/index.html"),
|
filepath.FromSlash("public/sect/doc11/index.html"),
|
||||||
"<p><strong>Tags:</strong> 2</p>\n"},
|
"<p><strong>Tags:</strong> 2</p>\n"},
|
||||||
|
{"sect/doc12.md", `---
|
||||||
|
title: "Foo"
|
||||||
|
---
|
||||||
|
|
||||||
|
{{% html-indented-v1 %}}`,
|
||||||
|
"public/sect/doc12/index.html",
|
||||||
|
"<h1>Hugo!</h1>"},
|
||||||
}
|
}
|
||||||
|
|
||||||
sources := make([][2]string, len(tests))
|
sources := make([][2]string, len(tests))
|
||||||
|
@ -545,6 +552,9 @@ tags:
|
||||||
templ.AddTemplate("_internal/shortcodes/b.html", `b`)
|
templ.AddTemplate("_internal/shortcodes/b.html", `b`)
|
||||||
templ.AddTemplate("_internal/shortcodes/c.html", `c`)
|
templ.AddTemplate("_internal/shortcodes/c.html", `c`)
|
||||||
templ.AddTemplate("_internal/shortcodes/d.html", `d`)
|
templ.AddTemplate("_internal/shortcodes/d.html", `d`)
|
||||||
|
templ.AddTemplate("_internal/shortcodes/html-indented-v1.html", "{{ $_hugo_config := `{ \"version\": 1 }` }}"+`
|
||||||
|
<h1>Hugo!</h1>
|
||||||
|
`)
|
||||||
templ.AddTemplate("_internal/shortcodes/menu.html", `{{ len (index .Page.Menus "main").Children }}`)
|
templ.AddTemplate("_internal/shortcodes/menu.html", `{{ len (index .Page.Menus "main").Children }}`)
|
||||||
templ.AddTemplate("_internal/shortcodes/tags.html", `{{ len .Page.Site.Taxonomies.tags }}`)
|
templ.AddTemplate("_internal/shortcodes/tags.html", `{{ len .Page.Site.Taxonomies.tags }}`)
|
||||||
|
|
||||||
|
@ -577,7 +587,7 @@ tags:
|
||||||
th := testHelper{s.Cfg, s.Fs, t}
|
th := testHelper{s.Cfg, s.Fs, t}
|
||||||
|
|
||||||
expected := cast.ToStringSlice(test.expected)
|
expected := cast.ToStringSlice(test.expected)
|
||||||
th.assertFileContent(test.outFile, expected...)
|
th.assertFileContent(filepath.FromSlash(test.outFile), expected...)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue