Fix string comparison for .Truncated page variable
authorAnthony Fok <foka@debian.org>
Tue, 20 Jan 2015 22:50:32 +0000 (15:50 -0700)
committerAnthony Fok <foka@debian.org>
Tue, 20 Jan 2015 22:50:32 +0000 (15:50 -0700)
Instead of `strings.TrimSpace()`, use `strings.Join(strings.Fields(s), " ")`
to collapse all whitespaces into single spaces, in order to match the
behaviour of helpers.TruncateWordsToWholeSentence(),
in order to detect non-truncated content correctly.

hugolib/page.go

index 1383f387ed86b2acac1f2f882b5172ad0b666524..479aa139881035d9a476091284a9078258d99280 100644 (file)
@@ -169,7 +169,7 @@ func (p *Page) setSummary() {
        } else {
                // If hugo defines split:
                // render, strip html, then split
-               plain := strings.TrimSpace(p.Plain())
+               plain := strings.Join(strings.Fields(p.Plain()), " ")
                p.Summary = helpers.BytesToHTML([]byte(helpers.TruncateWordsToWholeSentence(plain, helpers.SummaryLength)))
                p.Truncated = len(p.Summary) != len(plain)
        }