]> Cypherpunks repositories - gostls13.git/commitdiff
html: parse <xmp> tags
authorAndrew Balholm <andybalholm@gmail.com>
Wed, 30 Nov 2011 04:37:41 +0000 (15:37 +1100)
committerNigel Tao <nigeltao@golang.org>
Wed, 30 Nov 2011 04:37:41 +0000 (15:37 +1100)
Pass tests5.dat, test 10:
<p><xmp></xmp>

| <html>
|   <head>
|   <body>
|     <p>
|     <xmp>

Also pass the remaining tests in tests5.dat.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5440062

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

index 3011064e74f16abd68c925c445e765e94344efbd..45dc19150cf88c87efd8485f63d0928b876effda 100644 (file)
@@ -770,6 +770,11 @@ func inBodyIM(p *parser) bool {
                        p.oe.pop()
                        p.oe.pop()
                        p.form = nil
+               case "xmp":
+                       p.popUntil(buttonScopeStopTags, "p")
+                       p.reconstructActiveFormattingElements()
+                       p.framesetOK = false
+                       p.addElement(p.tok.Data, p.tok.Attr)
                case "caption", "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th", "thead", "tr":
                        // Ignore the token.
                default:
index 1e39f3ed70bc79318ef4a27b889903fb84e3c9c2..ea72557a0b04ce5be692da79936129b5908f5024 100644 (file)
@@ -154,7 +154,7 @@ func TestParser(t *testing.T) {
                {"tests2.dat", -1},
                {"tests3.dat", -1},
                // tests4.dat is fragment cases.
-               {"tests5.dat", 10},
+               {"tests5.dat", -1},
        }
        for _, tf := range testFiles {
                f, err := os.Open("testdata/webkit/" + tf.filename)
index 2a57566fd43373674ec0940b62be508725efdca7..7e1a4669657d1fce4262272eafff29992aeb0b71 100644 (file)
@@ -185,7 +185,7 @@ func render1(w writer, n *Node) error {
 
        // Render any child nodes.
        switch n.Data {
-       case "iframe", "noembed", "noframes", "noscript", "plaintext", "script", "style":
+       case "iframe", "noembed", "noframes", "noscript", "plaintext", "script", "style", "xmp":
                for _, c := range n.Child {
                        if c.Type != TextNode {
                                return fmt.Errorf("html: raw text element <%s> has non-text child node", n.Data)
index 2a2f96bbab63fa6a20ecb5ea042ceb09ecee299b..57e70ffeed5da033753e4461625c99b15bd80ea7 100644 (file)
@@ -406,12 +406,12 @@ func (z *Tokenizer) readStartTag() TokenType {
                }
        }
        // Several tags flag the tokenizer's next token as raw.
-       // The tag name lengths of these special cases ranges in [5, 9].
-       if x := z.data.end - z.data.start; 5 <= x && x <= 9 {
+       // The tag name lengths of these special cases ranges in [3, 9].
+       if x := z.data.end - z.data.start; 3 <= x && x <= 9 {
                switch z.buf[z.data.start] {
-               case 'i', 'n', 'p', 's', 't', 'I', 'N', 'P', 'S', 'T':
+               case 'i', 'n', 'p', 's', 't', 'x', 'I', 'N', 'P', 'S', 'T', 'X':
                        switch s := strings.ToLower(string(z.buf[z.data.start:z.data.end])); s {
-                       case "iframe", "noembed", "noframes", "noscript", "plaintext", "script", "style", "textarea", "title":
+                       case "iframe", "noembed", "noframes", "noscript", "plaintext", "script", "style", "textarea", "title", "xmp":
                                z.rawTag = s
                        }
                }