Commit fb72965d authored by Russ Cox's avatar Russ Cox

go/doc: update header rules

Go documentation can have header lines, which are single-line paragraphs
with leading and trailing letters and almost no punctuation.
Before this CL, the only allowed punctuation was ' followed by s.

After this CL, parentheses and commas are also allowed,
to pick up a pair of previously unrecognized headings in the
go command documentation:

	Gofmt (reformat) package sources
	Modules, module versions, and more

Change-Id: I6d59c40a1269f01cef62a3fb17b909571c2f2adb
Reviewed-on: https://go-review.googlesource.com/122407
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: default avatarAndrew Bonventre <andybons@golang.org>
parent c5ac91d0
...@@ -231,8 +231,8 @@ func heading(line string) string { ...@@ -231,8 +231,8 @@ func heading(line string) string {
return "" return ""
} }
// exclude lines with illegal characters // exclude lines with illegal characters. we allow "(),"
if strings.ContainsAny(line, ",.;:!?+*/=()[]{}_^°&§~%#@<\">\\") { if strings.ContainsAny(line, ".;:!?+*/=[]{}_^°&§~%#@<\">\\") {
return "" return ""
} }
...@@ -281,7 +281,7 @@ func anchorID(line string) string { ...@@ -281,7 +281,7 @@ func anchorID(line string) string {
// a single paragraph. There is one exception to the rule: a span that // a single paragraph. There is one exception to the rule: a span that
// consists of a single line, is followed by another paragraph span, // consists of a single line, is followed by another paragraph span,
// begins with a capital letter, and contains no punctuation // begins with a capital letter, and contains no punctuation
// is formatted as a heading. // other than parentheses and commas is formatted as a heading.
// //
// A span of indented lines is converted into a <pre> block, // A span of indented lines is converted into a <pre> block,
// with the common indent prefix removed. // with the common indent prefix removed.
......
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