]> Cypherpunks repositories - gostls13.git/commitdiff
html: auto-close <dd> and <dt> elements
authorAndrew Balholm <andybalholm@gmail.com>
Sun, 13 Nov 2011 12:27:20 +0000 (23:27 +1100)
committerNigel Tao <nigeltao@golang.org>
Sun, 13 Nov 2011 12:27:20 +0000 (23:27 +1100)
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

src/pkg/html/parse.go
src/pkg/html/parse_test.go

index d6505c691332d66e2c450c7c15aedf804d71cb4a..e8edcf956fb8f6a547c95f1d3902aaef5608e7eb 100644 (file)
@@ -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()
index 13c50a99bc1e7d922e4021561d5c51d7c41c49e7..992f73b060e36cdcd565845a1def9b6293ec390d 100644 (file)
@@ -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 {