diff options
| author | Andrew Balholm <andybalholm@gmail.com> | 2011-12-02 11:46:24 +1100 |
|---|---|---|
| committer | Nigel Tao <nigeltao@golang.org> | 2011-12-02 11:46:24 +1100 |
| commit | a5d300862b683e6a6d0e503c213d191155d1f63b (patch) | |
| tree | 880b9eb3a4067a373193edf7a73c6eb604bb8841 /src/pkg/html/parse.go | |
| parent | 6ea3a268b6263db0c98dbeb8076b1aa710d8f498 (diff) | |
| download | go-a5d300862b683e6a6d0e503c213d191155d1f63b.tar.xz | |
html: allow whitespace between head and body
Also ignore <head> tag after </head>.
Pass tests6.dat, test 0:
<!doctype html></head> <head>
| <!DOCTYPE html>
| <html>
| <head>
| " "
| <body>
Also pass tests through test 6:
<body>
<div>
R=nigeltao
CC=golang-dev
https://golang.org/cl/5447064
Diffstat (limited to 'src/pkg/html/parse.go')
| -rw-r--r-- | src/pkg/html/parse.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go index 97fbc514d8..dd2d8165bd 100644 --- a/src/pkg/html/parse.go +++ b/src/pkg/html/parse.go @@ -515,7 +515,19 @@ func afterHeadIM(p *parser) bool { implied bool ) switch p.tok.Type { - case ErrorToken, TextToken: + case ErrorToken: + implied = true + framesetOK = true + case TextToken: + s := strings.TrimLeft(p.tok.Data, whitespace) + if len(s) < len(p.tok.Data) { + // Add the initial whitespace to the current node. + p.addText(p.tok.Data[:len(p.tok.Data)-len(s)]) + if s == "" { + return true + } + p.tok.Data = s + } implied = true framesetOK = true case StartTagToken: @@ -535,7 +547,8 @@ func afterHeadIM(p *parser) bool { defer p.oe.pop() return inHeadIM(p) case "head": - // TODO. + // Ignore the token. + return true default: implied = true framesetOK = true |
