diff --git a/internal/godoc/dochtml/internal/render/linkify_test.go b/internal/godoc/dochtml/internal/render/linkify_test.go index bbcf5e767..9c8bc83a7 100644 --- a/internal/godoc/dochtml/internal/render/linkify_test.go +++ b/internal/godoc/dochtml/internal/render/linkify_test.go @@ -296,6 +296,18 @@ b := 1 line comment. */ +`, + }, + { + "An Output comment must appear at the start of the line.", + `_ = true +// This comment containing "// Output:" is not treated specially. +`, + ` +
+_ = true +// This comment containing "// Output:" is not treated specially. +`, }, } { diff --git a/internal/godoc/dochtml/internal/render/render.go b/internal/godoc/dochtml/internal/render/render.go index dc133d9fa..157fd9d44 100644 --- a/internal/godoc/dochtml/internal/render/render.go +++ b/internal/godoc/dochtml/internal/render/render.go @@ -21,7 +21,8 @@ import ( var ( // Regexp for example outputs. - exampleOutputRx = regexp.MustCompile(`(?i)//[[:space:]]*(unordered )?output:`) + // Keep consistent with outputPrefix in GOROOT/src/go/doc/example.go. + exampleOutputRx = regexp.MustCompile(`(?i)^[[:space:]]*//[[:space:]]*(unordered )?output:`) ) type Renderer struct {