diff options
author | Robert Griesemer <gri@golang.org> | 2010-07-26 17:34:40 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2010-07-26 17:34:40 -0700 |
commit | 0b133d8ac1c85d0c1d207ae0f35e9feea70c08a7 (patch) | |
tree | 2bcb2f0b69abec538ed26d750f3dc84bf88b6f5b | |
parent | f20c2e1cf5fa9e7bbb78f990e083d6e58864f179 (diff) | |
download | go-0b133d8ac1c85d0c1d207ae0f35e9feea70c08a7.tar.gz go-0b133d8ac1c85d0c1d207ae0f35e9feea70c08a7.zip |
godoc: accept '.', '!', and '?' as end of first sentence of package documentation
R=rsc
CC=golang-dev
https://golang.org/cl/1875049
-rw-r--r-- | src/cmd/godoc/godoc.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go index 658749b879..9daaacdb3f 100644 --- a/src/cmd/godoc/godoc.go +++ b/src/cmd/godoc/godoc.go @@ -152,18 +152,18 @@ func htmlEscape(s string) string { func firstSentence(s string) string { - i := -1 // index+1 of first period - j := -1 // index+1 of first period that is followed by white space + i := -1 // index+1 of first terminator (punctuation ending a sentence) + j := -1 // index+1 of first terminator followed by white space prev := 'A' for k, ch := range s { k1 := k + 1 - if ch == '.' { + if ch == '.' || ch == '!' || ch == '?' { if i < 0 { - i = k1 // first period + i = k1 // first terminator } if k1 < len(s) && s[k1] <= ' ' { if j < 0 { - j = k1 // first period followed by white space + j = k1 // first terminator followed by white space } if !unicode.IsUpper(prev) { j = k1 @@ -175,10 +175,10 @@ func firstSentence(s string) string { } if j < 0 { - // use the next best period + // use the next best terminator j = i if j < 0 { - // no period at all, use the entire string + // no terminator at all, use the entire string j = len(s) } } |