diff --git a/src/pkg/go/doc/headscan.go b/src/pkg/go/doc/headscan.go
index f559347638..1ccaa15819 100644
--- a/src/pkg/go/doc/headscan.go
+++ b/src/pkg/go/doc/headscan.go
@@ -24,6 +24,7 @@ import (
"go/token"
"os"
"path/filepath"
+ "regexp"
"runtime"
"strings"
)
@@ -33,10 +34,10 @@ var (
verbose = flag.Bool("v", false, "verbose mode")
)
-const (
- html_h = "
"
- html_endh = "
\n"
-)
+// ToHTML in comment.go assigns a (possibly blank) ID to each heading
+var html_h = regexp.MustCompile(``)
+
+const html_endh = "
\n"
func isGoFile(fi os.FileInfo) bool {
return strings.HasSuffix(fi.Name(), ".go") &&
@@ -47,11 +48,11 @@ func appendHeadings(list []string, comment string) []string {
var buf bytes.Buffer
doc.ToHTML(&buf, comment, nil)
for s := buf.String(); ; {
- i := strings.Index(s, html_h)
- if i < 0 {
+ loc := html_h.FindStringIndex(s)
+ if len(loc) == 0 {
break
}
- i += len(html_h)
+ i := loc[1]
j := strings.Index(s, html_endh)
if j < 0 {
list = append(list, s[i:]) // incorrect HTML