aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/html/parse.go
diff options
context:
space:
mode:
authorAndrew Balholm <andybalholm@gmail.com>2011-11-16 12:18:11 +1100
committerNigel Tao <nigeltao@golang.org>2011-11-16 12:18:11 +1100
commit28546ed56a37c7d4a384c1e9ae69c61d16e4ea94 (patch)
treed074f3274177ff3530af8817582b5b24747af1a2 /src/pkg/html/parse.go
parent5e5c5c2789cb585122ed5975dbe11d7bf761b7a0 (diff)
downloadgo-28546ed56a37c7d4a384c1e9ae69c61d16e4ea94.tar.xz
html: parse <caption> elements
Pass tests2.dat, test 33: <!DOCTYPE html><table><caption>test TEST</caption><td>test | <!DOCTYPE html> | <html> | <head> | <body> | <table> | <caption> | "test TEST" | <tbody> | <tr> | <td> | "test" R=nigeltao CC=golang-dev https://golang.org/cl/5371099
Diffstat (limited to 'src/pkg/html/parse.go')
-rw-r--r--src/pkg/html/parse.go48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go
index 5b91204240..2c15d2d31e 100644
--- a/src/pkg/html/parse.go
+++ b/src/pkg/html/parse.go
@@ -298,7 +298,7 @@ func (p *parser) resetInsertionMode() {
case "tbody", "thead", "tfoot":
p.im = inTableBodyIM
case "caption":
- // TODO: p.im = inCaptionIM
+ p.im = inCaptionIM
case "colgroup":
p.im = inColumnGroupIM
case "table":
@@ -887,6 +887,12 @@ func inTableIM(p *parser) bool {
// TODO.
case StartTagToken:
switch p.tok.Data {
+ case "caption":
+ p.clearStackToContext(tableScopeStopTags)
+ p.afe = append(p.afe, &scopeMarker)
+ p.addElement(p.tok.Data, p.tok.Attr)
+ p.im = inCaptionIM
+ return true
case "tbody", "tfoot", "thead":
p.clearStackToContext(tableScopeStopTags)
p.addElement(p.tok.Data, p.tok.Attr)
@@ -960,6 +966,46 @@ func (p *parser) clearStackToContext(stopTags []string) {
}
}
+// Section 11.2.5.4.11.
+func inCaptionIM(p *parser) bool {
+ switch p.tok.Type {
+ case StartTagToken:
+ switch p.tok.Data {
+ case "caption", "col", "colgroup", "tbody", "td", "tfoot", "thead", "tr":
+ if p.popUntil(tableScopeStopTags, "caption") {
+ p.clearActiveFormattingElements()
+ p.im = inTableIM
+ return false
+ } else {
+ // Ignore the token.
+ return true
+ }
+ }
+ case EndTagToken:
+ switch p.tok.Data {
+ case "caption":
+ if p.popUntil(tableScopeStopTags, "caption") {
+ p.clearActiveFormattingElements()
+ p.im = inTableIM
+ }
+ return true
+ case "table":
+ if p.popUntil(tableScopeStopTags, "caption") {
+ p.clearActiveFormattingElements()
+ p.im = inTableIM
+ return false
+ } else {
+ // Ignore the token.
+ return true
+ }
+ case "body", "col", "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr":
+ // Ignore the token.
+ return true
+ }
+ }
+ return inBodyIM(p)
+}
+
// Section 11.2.5.4.12.
func inColumnGroupIM(p *parser) bool {
switch p.tok.Type {