shithub: hugo

Download patch

ref: 02da49597dce2e8206495eb3f778b22126ca6724
parent: a17c290a33bd44fd058f44c994893df892f783f6
author: Anthony Fok <[email protected]>
date: Tue Jan 20 10:50:32 EST 2015

Fix string comparison for .Truncated page variable

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.

--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -169,7 +169,7 @@
 	} 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)
 	}