Fix Truncate

TruncateWordsToWholeSentence knows if the summary is truncated, so let "him" decide.

Fixes #880
This commit is contained in:
bep
2015-02-05 21:44:15 +01:00
committed by Anthony Fok
parent 2bee4a1570
commit 48b6777ea2
3 changed files with 39 additions and 10 deletions

View File

@@ -190,10 +190,9 @@ func (p *Page) setSummary() {
} else {
// If hugo defines split:
// render, strip html, then split
p.Summary = helpers.BytesToHTML([]byte(helpers.TruncateWordsToWholeSentence(p.PlainWords(), helpers.SummaryLength)))
// todo bep - check if the Plain() can be trimmed earlier
p.Truncated = len(p.Summary) != len(strings.Trim(p.Plain(), "\n\r "))
summary, truncated := helpers.TruncateWordsToWholeSentence(p.PlainWords(), helpers.SummaryLength)
p.Summary = helpers.BytesToHTML([]byte(summary))
p.Truncated = truncated
}
}