aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/html/parse.go
diff options
context:
space:
mode:
authorAndrew Balholm <andybalholm@gmail.com>2011-11-11 11:41:46 +1100
committerNigel Tao <nigeltao@golang.org>2011-11-11 11:41:46 +1100
commit83f61a27d6f1ef053c00b4cc2fd9668fdf354ad8 (patch)
tree27bd8629dac9b5bb8f13034e94707c9bc7dacfd1 /src/pkg/html/parse.go
parentdd2abe51526867b7574a10708a028a24a3a41ad9 (diff)
downloadgo-83f61a27d6f1ef053c00b4cc2fd9668fdf354ad8.tar.xz
html: parse column groups
Pass tests1.dat, test 108: <table><colgroup><col><colgroup><col><col><col><colgroup><col><col><thead><tr><td></table> | <html> | <head> | <body> | <table> | <colgroup> | <col> | <colgroup> | <col> | <col> | <col> | <colgroup> | <col> | <col> | <thead> | <tr> | <td> R=nigeltao CC=golang-dev https://golang.org/cl/5369061
Diffstat (limited to 'src/pkg/html/parse.go')
-rw-r--r--src/pkg/html/parse.go50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go
index eb0d5c2d09..6aef7e12ed 100644
--- a/src/pkg/html/parse.go
+++ b/src/pkg/html/parse.go
@@ -313,7 +313,7 @@ func (p *parser) resetInsertionMode() insertionMode {
case "caption":
// TODO: return inCaptionIM
case "colgroup":
- // TODO: return inColumnGroupIM
+ return inColumnGroupIM
case "table":
return inTableIM
case "head":
@@ -879,6 +879,14 @@ func inTableIM(p *parser) (insertionMode, bool) {
}
// Ignore the token.
return inTableIM, true
+ case "colgroup":
+ p.clearStackToContext(tableScopeStopTags)
+ p.addElement(p.tok.Data, p.tok.Attr)
+ return inColumnGroupIM, true
+ case "col":
+ p.clearStackToContext(tableScopeStopTags)
+ p.addElement("colgroup", p.tok.Attr)
+ return inColumnGroupIM, false
default:
// TODO.
}
@@ -924,6 +932,46 @@ func (p *parser) clearStackToContext(stopTags []string) {
}
}
+// Section 11.2.5.4.12.
+func inColumnGroupIM(p *parser) (insertionMode, bool) {
+ switch p.tok.Type {
+ case CommentToken:
+ p.addChild(&Node{
+ Type: CommentNode,
+ Data: p.tok.Data,
+ })
+ return inColumnGroupIM, true
+ case DoctypeToken:
+ // Ignore the token.
+ return inColumnGroupIM, true
+ case StartTagToken:
+ switch p.tok.Data {
+ case "html":
+ return useTheRulesFor(p, inColumnGroupIM, inBodyIM)
+ case "col":
+ p.addElement(p.tok.Data, p.tok.Attr)
+ p.oe.pop()
+ p.acknowledgeSelfClosingTag()
+ return inColumnGroupIM, true
+ }
+ case EndTagToken:
+ switch p.tok.Data {
+ case "colgroup":
+ if p.oe.top().Data != "html" {
+ p.oe.pop()
+ }
+ return inTableIM, true
+ case "col":
+ // Ignore the token.
+ return inColumnGroupIM, true
+ }
+ }
+ if p.oe.top().Data != "html" {
+ p.oe.pop()
+ }
+ return inTableIM, false
+}
+
// Section 11.2.5.4.13.
func inTableBodyIM(p *parser) (insertionMode, bool) {
var (