Fix .WordCount, .FuzzyWordCount, .ReadingTime when summary marker is set

This bug was introduced in Hugo 0.40. It is when you use the `<!--more-->` summary marker.

Note that this affects the word stats only. The related `PlainWords`, `Plain`, `Content` all return correct values.

Fixes #4675
Fixes #4682
This commit is contained in:
Bjørn Erik Pedersen 2018-04-27 10:17:01 +02:00
parent 391f59f996
commit 001a28c2f9
3 changed files with 114 additions and 5 deletions

View file

@ -493,7 +493,10 @@ func totalWordsOld(s string) int {
}
// TruncateWordsByRune truncates words by runes.
func (c *ContentSpec) TruncateWordsByRune(words []string) (string, bool) {
func (c *ContentSpec) TruncateWordsByRune(in []string) (string, bool) {
words := make([]string, len(in))
copy(words, in)
count := 0
for index, word := range words {
if count >= c.summaryLength {