Commit e8b580c9 authored by Robert Griesemer's avatar Robert Griesemer

fix sentence extraction

R=rsc
http://go/go-review/1026027
parent 202ede12
......@@ -137,14 +137,21 @@ func htmlEscape(s string) string {
func firstSentence(s string) string {
i := strings.Index(s, ". ");
if i < 0 {
i = strings.Index(s, ".");
if i < 0 {
i = len(s)-1; // compensate for i+1 below
// find first period followed by whitespace, or just the first period
i := -1;
for j, ch := range s {
if ch == '.' {
i = j+1; // include period
if i < len(s) && s[i] <= ' ' {
break;
}
}
}
return s[0 : i+1]; // include ".", if any
if i < 0 {
// no period found, use the enire string
i = len(s);
}
return s[0:i];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment