Commit 06ef97e1 authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

html: auto-close <dd> and <dt> elements

Pass tests2.dat, test 8:
<!DOCTYPE html><dt><div><dd>

| <!DOCTYPE html>
| <html>
|   <head>
|   <body>
|     <dt>
|       <div>
|     <dd>

Also pass tests through test 9:
<script></x

R=nigeltao
CC=golang-dev
https://golang.org/cl/5373083
parent 631a575f
......@@ -637,6 +637,24 @@ func inBodyIM(p *parser) bool {
}
p.popUntil(buttonScopeStopTags, "p")
p.addElement(p.tok.Data, p.tok.Attr)
case "dd", "dt":
p.framesetOK = false
for i := len(p.oe) - 1; i >= 0; i-- {
node := p.oe[i]
switch node.Data {
case "dd", "dt":
p.oe = p.oe[:i]
case "address", "div", "p":
continue
default:
if !isSpecialElement[node.Data] {
continue
}
}
break
}
p.popUntil(buttonScopeStopTags, "p")
p.addElement(p.tok.Data, p.tok.Attr)
case "optgroup", "option":
if p.top().Data == "option" {
p.oe.pop()
......
......@@ -134,7 +134,7 @@ func TestParser(t *testing.T) {
}{
// TODO(nigeltao): Process all the test cases from all the .dat files.
{"tests1.dat", -1},
{"tests2.dat", 0},
{"tests2.dat", 10},
{"tests3.dat", 0},
}
for _, tf := range testFiles {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment