Commit a88bbbb7 authored by Andrew Gerrand's avatar Andrew Gerrand

go/doc: trim only first space or newline from example output comment

Fixes #4487.

R=rsc
CC=golang-dev
https://golang.org/cl/7057048
parent 02370f67
......@@ -84,7 +84,13 @@ func exampleOutput(b *ast.BlockStmt, comments []*ast.CommentGroup) string {
// test that it begins with the correct prefix
text := last.Text()
if loc := outputPrefix.FindStringIndex(text); loc != nil {
return strings.TrimSpace(text[loc[1]:])
text = text[loc[1]:]
// Strip zero or more spaces followed by \n or a single space.
text = strings.TrimLeft(text, " ")
if len(text) > 0 && text[0] == '\n' {
text = text[1:]
}
return text
}
}
return "" // no suitable comment found
......
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