mirror of
https://github.com/golang/go
synced 2024-11-20 01:04:40 -07:00
html: handle end tags in strange places
Pass tests1.dat, test 111: </strong></b></em></i></u></strike></s></blink></tt></pre></big></small></font></select></h1></h2></h3></h4></h5></h6></body></br></a></img></title></span></style></script></table></th></td></tr></frame></area></link></param></hr></input></col></base></meta></basefont></bgsound></embed></spacer></p></dd></dt></caption></colgroup></tbody></tfoot></thead></address></blockquote></center></dir></div></dl></fieldset></listing></menu></ol></ul></li></nobr></wbr></form></button></marquee></object></html></frameset></head></iframe></image></isindex></noembed></noframes></noscript></optgroup></option></plaintext></textarea> | <html> | <head> | <body> | <br> | <p> Also pass all the remaining tests in tests1.dat. R=nigeltao CC=golang-dev https://golang.org/cl/5372066
This commit is contained in:
parent
e8188c1607
commit
3df0512469
@ -352,30 +352,19 @@ func initialIM(p *parser) (insertionMode, bool) {
|
||||
|
||||
// Section 11.2.5.4.2.
|
||||
func beforeHTMLIM(p *parser) (insertionMode, bool) {
|
||||
var (
|
||||
add bool
|
||||
attr []Attribute
|
||||
implied bool
|
||||
)
|
||||
switch p.tok.Type {
|
||||
case ErrorToken:
|
||||
implied = true
|
||||
case TextToken:
|
||||
// TODO: distinguish whitespace text from others.
|
||||
implied = true
|
||||
case StartTagToken:
|
||||
if p.tok.Data == "html" {
|
||||
add = true
|
||||
attr = p.tok.Attr
|
||||
} else {
|
||||
implied = true
|
||||
p.addElement(p.tok.Data, p.tok.Attr)
|
||||
return beforeHeadIM, true
|
||||
}
|
||||
case EndTagToken:
|
||||
switch p.tok.Data {
|
||||
case "head", "body", "html", "br":
|
||||
implied = true
|
||||
// Drop down to creating an implied <html> tag.
|
||||
default:
|
||||
// Ignore the token.
|
||||
return beforeHTMLIM, true
|
||||
}
|
||||
case CommentToken:
|
||||
p.doc.Add(&Node{
|
||||
@ -384,10 +373,9 @@ func beforeHTMLIM(p *parser) (insertionMode, bool) {
|
||||
})
|
||||
return beforeHTMLIM, true
|
||||
}
|
||||
if add || implied {
|
||||
p.addElement("html", attr)
|
||||
}
|
||||
return beforeHeadIM, !implied
|
||||
// Create an implied <html> tag.
|
||||
p.addElement("html", nil)
|
||||
return beforeHeadIM, false
|
||||
}
|
||||
|
||||
// Section 11.2.5.4.3.
|
||||
@ -691,6 +679,9 @@ func inBodyIM(p *parser) (insertionMode, bool) {
|
||||
if p.popUntil(defaultScopeStopTags, p.tok.Data) {
|
||||
p.clearActiveFormattingElements()
|
||||
}
|
||||
case "br":
|
||||
p.tok.Type = StartTagToken
|
||||
return inBodyIM, false
|
||||
default:
|
||||
p.inBodyEndTagOther(p.tok.Data)
|
||||
}
|
||||
@ -1192,18 +1183,15 @@ func inSelectIM(p *parser) (insertionMode, bool) {
|
||||
func afterBodyIM(p *parser) (insertionMode, bool) {
|
||||
switch p.tok.Type {
|
||||
case ErrorToken:
|
||||
// TODO.
|
||||
case TextToken:
|
||||
// TODO.
|
||||
// Stop parsing.
|
||||
return nil, true
|
||||
case StartTagToken:
|
||||
// TODO.
|
||||
if p.tok.Data == "html" {
|
||||
return useTheRulesFor(p, afterBodyIM, inBodyIM)
|
||||
}
|
||||
case EndTagToken:
|
||||
switch p.tok.Data {
|
||||
case "html":
|
||||
// TODO: autoclose the stack of open elements.
|
||||
if p.tok.Data == "html" {
|
||||
return afterAfterBodyIM, true
|
||||
default:
|
||||
// TODO.
|
||||
}
|
||||
case CommentToken:
|
||||
// The comment is attached to the <html> element.
|
||||
@ -1216,8 +1204,7 @@ func afterBodyIM(p *parser) (insertionMode, bool) {
|
||||
})
|
||||
return afterBodyIM, true
|
||||
}
|
||||
// TODO: should this be "return inBodyIM, true"?
|
||||
return afterBodyIM, true
|
||||
return inBodyIM, false
|
||||
}
|
||||
|
||||
// Section 11.2.5.4.19.
|
||||
|
@ -133,7 +133,7 @@ func TestParser(t *testing.T) {
|
||||
n int
|
||||
}{
|
||||
// TODO(nigeltao): Process all the test cases from all the .dat files.
|
||||
{"tests1.dat", 111},
|
||||
{"tests1.dat", -1},
|
||||
{"tests2.dat", 0},
|
||||
{"tests3.dat", 0},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user