// Stop parsing.
return true
case TextToken:
- // TODO.
+ p.tok.Data = strings.Replace(p.tok.Data, "\x00", "", -1)
+ switch p.oe.top().Data {
+ case "table", "tbody", "tfoot", "thead", "tr":
+ if strings.Trim(p.tok.Data, whitespace) == "" {
+ p.addText(p.tok.Data)
+ return true
+ }
+ }
case StartTagToken:
switch p.tok.Data {
case "caption":
p.addElement(p.tok.Data, p.tok.Attr)
p.im = inCaptionIM
return true
+ case "colgroup":
+ p.clearStackToContext(tableScope)
+ p.addElement(p.tok.Data, p.tok.Attr)
+ p.im = inColumnGroupIM
+ return true
+ case "col":
+ p.parseImpliedToken(StartTagToken, "colgroup", nil)
+ return false
case "tbody", "tfoot", "thead":
p.clearStackToContext(tableScope)
p.addElement(p.tok.Data, p.tok.Attr)
p.im = inTableBodyIM
return true
case "td", "th", "tr":
- p.clearStackToContext(tableScope)
- p.addElement("tbody", nil)
- p.im = inTableBodyIM
+ p.parseImpliedToken(StartTagToken, "tbody", nil)
return false
case "table":
if p.popUntil(tableScope, "table") {
}
// Ignore the token.
return true
- case "colgroup":
- p.clearStackToContext(tableScope)
+ case "style", "script":
+ return inHeadIM(p)
+ case "input":
+ for _, a := range p.tok.Attr {
+ if a.Key == "type" && strings.ToLower(a.Val) == "hidden" {
+ p.addElement(p.tok.Data, p.tok.Attr)
+ p.oe.pop()
+ return true
+ }
+ }
+ // Otherwise drop down to the default action.
+ case "form":
+ if p.form != nil {
+ // Ignore the token.
+ return true
+ }
p.addElement(p.tok.Data, p.tok.Attr)
- p.im = inColumnGroupIM
- return true
- case "col":
- p.clearStackToContext(tableScope)
- p.addElement("colgroup", p.tok.Attr)
- p.im = inColumnGroupIM
- return false
+ p.form = p.oe.pop()
case "select":
p.reconstructActiveFormattingElements()
switch p.top().Data {
p.framesetOK = false
p.im = inSelectInTableIM
return true
- default:
- // TODO.
}
case EndTagToken:
switch p.tok.Data {
Data: p.tok.Data,
})
return true
+ case DoctypeToken:
+ // Ignore the token.
+ return true
}
switch p.top().Data {
PASS "<style><!--</style>--></style>"
PASS "<style><!--</style>-->"
PASS "<ul><li>A </li> <li>B</li></ul>"
-FAIL "<table><form><input type=hidden><input></form><div></div></table>"
+PASS "<table><form><input type=hidden><input></form><div></div></table>"
PASS "<i>A<b>B<p></i>C</b>D"
PASS "<div></div>"
PASS "<svg></svg>"
PASS "<table><th>"
PASS "<table><td>"
-FAIL "<table><col foo='bar'>"
+PASS "<table><col foo='bar'>"
PASS "<table><colgroup></html>foo"
PASS "<table></table><p>foo"
PASS "<table></body></caption></col></colgroup></html></tbody></td></tfoot></th></thead></tr><td>"
PASS "<!doctype html><table> x</table>"
PASS "<!doctype html><table> x </table>"
PASS "<!doctype html><table><tr> x</table>"
-FAIL "<!doctype html><table>X<style> <tr>x </style> </table>"
-FAIL "<!doctype html><div><table><a>foo</a> <tr><td>bar</td> </tr></table></div>"
+PASS "<!doctype html><table>X<style> <tr>x </style> </table>"
+PASS "<!doctype html><div><table><a>foo</a> <tr><td>bar</td> </tr></table></div>"
PASS "<frame></frame></frame><frameset><frame><frameset><frame></frameset><noframes></frameset><noframes>"
PASS "<!DOCTYPE html><object></html>"
PASS "<noembed><!--<noembed></noembed>--></noembed>"
FAIL "<!doctype html><table>"
PASS "<!doctype html><table><td><span><font></span><span>"
-FAIL "<!doctype html><form><table></form><form></table></form>"
+PARSE "<!doctype html><form><table></form><form></table></form>"
PARSE "<!doctype html><table><tbody><tr><plaintext></plaintext>"
PASS "<!doctype html><table><td><plaintext></plaintext>"
PASS "<!doctype html><table><caption><plaintext></plaintext>"
-FAIL "<!doctype html><table><tr><style></script></style>abc"
-FAIL "<!doctype html><table><tr><script></style></script>abc"
+PASS "<!doctype html><table><tr><style></script></style>abc"
+PASS "<!doctype html><table><tr><script></style></script>abc"
PASS "<!doctype html><table><caption><style></script></style>abc"
PASS "<!doctype html><table><td><style></script></style>abc"
FAIL "<!doctype html><select><script></style></script>abc"
PASS "<!doctype html><p></h3>foo"
PASS "<!doctype html><h3><li>abc</h2>foo"
PASS "<!doctype html><table>abc<!--foo-->"
-FAIL "<!doctype html><table> <!--foo-->"
+PASS "<!doctype html><table> <!--foo-->"
PASS "<!doctype html><table> b <!--foo-->"
PASS "<!doctype html><select><option><option>"
PASS "<!doctype html><select><option></optgroup>"
PASS "<!doctype html><p><figcaption>"
PASS "<!doctype html><p><summary>"
PASS "<!doctype html><form><table><form>"
-FAIL "<!doctype html><table><form><form>"
-FAIL "<!doctype html><table><form></table><form>"
+PASS "<!doctype html><table><form><form>"
+PASS "<!doctype html><table><form></table><form>"
PASS "<!doctype html><svg><foreignObject><p>"
PASS "<!doctype html><svg><title>abc"
PASS "<option><span><option>"
FAIL "<!doctype html><head></head><title>X</title>"
FAIL "<!doctype html></head><title>X</title>"
PASS "<!doctype html><table><meta></table>"
-FAIL "<!doctype html><table>X<tr><td><table> <meta></table></table>"
+PASS "<!doctype html><table>X<tr><td><table> <meta></table></table>"
PASS "<!doctype html><html> <head>"
PASS "<!doctype html> <head>"
-FAIL "<!doctype html><table><style> <tr>x </style> </table>"
-FAIL "<!doctype html><table><TBODY><script> <tr>x </script> </table>"
+PASS "<!doctype html><table><style> <tr>x </style> </table>"
+PASS "<!doctype html><table><TBODY><script> <tr>x </script> </table>"
PASS "<!doctype html><p><applet><p>X</p></applet>"
PASS "<!doctype html><listing>\nX</listing>"
FAIL "<!doctype html><select><input>X"
PASS "<!doctype html><select><select>X"
-FAIL "<!doctype html><table><input type=hidDEN></table>"
-FAIL "<!doctype html><table>X<input type=hidDEN></table>"
-FAIL "<!doctype html><table> <input type=hidDEN></table>"
-FAIL "<!doctype html><table> <input type='hidDEN'></table>"
-FAIL "<!doctype html><table><input type=\" hidden\"><input type=hidDEN></table>"
+PASS "<!doctype html><table><input type=hidDEN></table>"
+PASS "<!doctype html><table>X<input type=hidDEN></table>"
+PASS "<!doctype html><table> <input type=hidDEN></table>"
+PASS "<!doctype html><table> <input type='hidDEN'></table>"
+PASS "<!doctype html><table><input type=\" hidden\"><input type=hidDEN></table>"
PASS "<!doctype html><table><select>X<tr>"
PASS "<!doctype html><select>X</select>"
PASS "<!DOCTYPE hTmL><html></html>"
PASS "<html><body>\n<p><font size=\"7\">First paragraph.</p>\n<p>Second paragraph.</p></font>\n<b><p><i>Bold and Italic</b> Italic</p>"
PASS "<html>\n<dl>\n<dt><b>Boo\n<dd>Goo?\n</dl>\n</html>"
PASS "<html><body>\n<label><a><div>Hello<div>World</div></a></label> \n</body></html>"
-FAIL "<table><center> <font>a</center> <img> <tr><td> </td> </tr> </table>"
+PASS "<table><center> <font>a</center> <img> <tr><td> </td> </tr> </table>"
FAIL "<table><tr><p><a><p>You should see this text."
-FAIL "<TABLE>\n<TR>\n<CENTER><CENTER><TD></TD></TR><TR>\n<FONT>\n<TABLE><tr></tr></TABLE>\n</P>\n<a></font><font></a>\nThis page contains an insanely badly-nested tag sequence."
+PASS "<TABLE>\n<TR>\n<CENTER><CENTER><TD></TD></TR><TR>\n<FONT>\n<TABLE><tr></tr></TABLE>\n</P>\n<a></font><font></a>\nThis page contains an insanely badly-nested tag sequence."
PASS "<html>\n<body>\n<b><nobr><div>This text is in a div inside a nobr</nobr>More text that should not be in the nobr, i.e., the\nnobr should have closed the div inside it implicitly. </b><pre>A pre tag outside everything else.</pre>\n</body>\n</html>"