hugolib: Make RawContent raw again

This was a regression introduced in Hugo 0.17.

Fixes #2601
This commit is contained in:
Bjørn Erik Pedersen
2016-12-01 10:21:49 +01:00
parent 971d1baf13
commit 2f026ab3f3
5 changed files with 53 additions and 22 deletions

View File

@@ -368,49 +368,49 @@ func (s *Site) preparePagesForRender(cfg *BuildCfg) {
// If in watch mode, we need to keep the original so we can
// repeat this process on rebuild.
var rawContentCopy []byte
var workContentCopy []byte
if cfg.Watching {
rawContentCopy = make([]byte, len(p.rawContent))
copy(rawContentCopy, p.rawContent)
workContentCopy = make([]byte, len(p.workContent))
copy(workContentCopy, p.workContent)
} else {
// Just reuse the same slice.
rawContentCopy = p.rawContent
workContentCopy = p.workContent
}
if p.Markup == "markdown" {
tmpContent, tmpTableOfContents := helpers.ExtractTOC(rawContentCopy)
tmpContent, tmpTableOfContents := helpers.ExtractTOC(workContentCopy)
p.TableOfContents = helpers.BytesToHTML(tmpTableOfContents)
rawContentCopy = tmpContent
workContentCopy = tmpContent
}
var err error
if rawContentCopy, err = handleShortcodes(p, s.owner.tmpl, rawContentCopy); err != nil {
if workContentCopy, err = handleShortcodes(p, s.owner.tmpl, workContentCopy); err != nil {
jww.ERROR.Printf("Failed to handle shortcodes for page %s: %s", p.BaseFileName(), err)
}
if p.Markup != "html" {
// Now we know enough to create a summary of the page and count some words
summaryContent, err := p.setUserDefinedSummaryIfProvided(rawContentCopy)
summaryContent, err := p.setUserDefinedSummaryIfProvided(workContentCopy)
if err != nil {
jww.ERROR.Printf("Failed to set user defined summary for page %q: %s", p.Path(), err)
} else if summaryContent != nil {
rawContentCopy = summaryContent.content
workContentCopy = summaryContent.content
}
p.Content = helpers.BytesToHTML(rawContentCopy)
p.Content = helpers.BytesToHTML(workContentCopy)
if summaryContent == nil {
p.setAutoSummary()
}
} else {
p.Content = helpers.BytesToHTML(rawContentCopy)
p.Content = helpers.BytesToHTML(workContentCopy)
}
// no need for this anymore
rawContentCopy = nil
workContentCopy = nil
//analyze for raw stats
p.analyzePage()