mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
a7b93e6564
commit
3a8aad6b19
2 changed files with 23 additions and 18 deletions
|
@ -328,6 +328,7 @@ func (p *pageState) RawContent() string {
|
||||||
if start == -1 {
|
if start == -1 {
|
||||||
start = 0
|
start = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(p.source.parsed.Input()[start:])
|
return string(p.source.parsed.Input()[start:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,9 +728,7 @@ Loop:
|
||||||
frontMatterSet = true
|
frontMatterSet = true
|
||||||
|
|
||||||
next := iter.Peek()
|
next := iter.Peek()
|
||||||
if !next.IsDone() {
|
p.source.posMainContent = next.Pos()
|
||||||
p.source.posMainContent = next.Pos()
|
|
||||||
}
|
|
||||||
|
|
||||||
if !p.s.shouldBuild(p) {
|
if !p.s.shouldBuild(p) {
|
||||||
// Nothing more to do.
|
// Nothing more to do.
|
||||||
|
|
|
@ -642,27 +642,33 @@ Simple Page With Some Date`
|
||||||
testAllMarkdownEnginesForPages(t, assertFunc, nil, pageContents...)
|
testAllMarkdownEnginesForPages(t, assertFunc, nil, pageContents...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue #2601
|
|
||||||
func TestPageRawContent(t *testing.T) {
|
func TestPageRawContent(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
c := qt.New(t)
|
|
||||||
cfg, fs := newTestCfg()
|
|
||||||
configs, err := loadTestConfigFromProvider(cfg)
|
|
||||||
c.Assert(err, qt.IsNil)
|
|
||||||
|
|
||||||
writeSource(t, fs, filepath.Join("content", "raw.md"), `---
|
files := `
|
||||||
title: Raw
|
-- hugo.toml --
|
||||||
|
-- content/basic.md --
|
||||||
---
|
---
|
||||||
**Raw**`)
|
title: "basic"
|
||||||
|
---
|
||||||
|
**basic**
|
||||||
|
-- content/empty.md --
|
||||||
|
---
|
||||||
|
title: "empty"
|
||||||
|
---
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
|{{ .RawContent }}|
|
||||||
|
`
|
||||||
|
|
||||||
writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), `{{ .RawContent }}`)
|
b := NewIntegrationTestBuilder(
|
||||||
|
IntegrationTestConfig{
|
||||||
|
T: t,
|
||||||
|
TxtarString: files,
|
||||||
|
},
|
||||||
|
).Build()
|
||||||
|
|
||||||
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Configs: configs}, BuildCfg{SkipRender: true})
|
b.AssertFileContent("public/basic/index.html", "|**basic**|")
|
||||||
|
b.AssertFileContent("public/empty/index.html", "! title")
|
||||||
|
|
||||||
c.Assert(len(s.RegularPages()), qt.Equals, 1)
|
|
||||||
p := s.RegularPages()[0]
|
|
||||||
|
|
||||||
c.Assert("**Raw**", qt.Equals, p.RawContent())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPageWithShortCodeInSummary(t *testing.T) {
|
func TestPageWithShortCodeInSummary(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue