diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go
index 67356e450c4..6962e643932 100644
--- a/src/pkg/html/parse.go
+++ b/src/pkg/html/parse.go
@@ -1572,6 +1572,19 @@ func afterAfterFramesetIM(p *parser) bool {
Type: CommentNode,
Data: p.tok.Data,
})
+ case TextToken:
+ // Ignore all text but whitespace.
+ s := strings.Map(func(c rune) rune {
+ switch c {
+ case ' ', '\t', '\n', '\f', '\r':
+ return c
+ }
+ return -1
+ }, p.tok.Data)
+ if s != "" {
+ p.reconstructActiveFormattingElements()
+ p.addText(s)
+ }
case StartTagToken:
switch p.tok.Data {
case "html":
diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go
index 1c2df5a7ee3..015b5838f0b 100644
--- a/src/pkg/html/parse_test.go
+++ b/src/pkg/html/parse_test.go
@@ -172,7 +172,7 @@ func TestParser(t *testing.T) {
{"tests3.dat", -1},
{"tests4.dat", -1},
{"tests5.dat", -1},
- {"tests6.dat", 45},
+ {"tests6.dat", 47},
{"tests10.dat", 16},
}
for _, tf := range testFiles {