OLD | NEW |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package html | 5 package html |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 a "exp/html/atom" | 9 a "exp/html/atom" |
10 "fmt" | 10 "fmt" |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 case a.Math, a.Svg: | 992 case a.Math, a.Svg: |
993 p.reconstructActiveFormattingElements() | 993 p.reconstructActiveFormattingElements() |
994 if p.tok.DataAtom == a.Math { | 994 if p.tok.DataAtom == a.Math { |
995 adjustAttributeNames(p.tok.Attr, mathMLAttribute
Adjustments) | 995 adjustAttributeNames(p.tok.Attr, mathMLAttribute
Adjustments) |
996 } else { | 996 } else { |
997 adjustAttributeNames(p.tok.Attr, svgAttributeAdj
ustments) | 997 adjustAttributeNames(p.tok.Attr, svgAttributeAdj
ustments) |
998 } | 998 } |
999 adjustForeignAttributes(p.tok.Attr) | 999 adjustForeignAttributes(p.tok.Attr) |
1000 p.addElement() | 1000 p.addElement() |
1001 p.top().Namespace = p.tok.Data | 1001 p.top().Namespace = p.tok.Data |
| 1002 if p.hasSelfClosingToken { |
| 1003 p.oe.pop() |
| 1004 p.acknowledgeSelfClosingTag() |
| 1005 } |
1002 return true | 1006 return true |
1003 case a.Caption, a.Col, a.Colgroup, a.Frame, a.Head, a.Tbody, a.T
d, a.Tfoot, a.Th, a.Thead, a.Tr: | 1007 case a.Caption, a.Col, a.Colgroup, a.Frame, a.Head, a.Tbody, a.T
d, a.Tfoot, a.Th, a.Thead, a.Tr: |
1004 // Ignore the token. | 1008 // Ignore the token. |
1005 default: | 1009 default: |
1006 p.reconstructActiveFormattingElements() | 1010 p.reconstructActiveFormattingElements() |
1007 p.addElement() | 1011 p.addElement() |
1008 } | 1012 } |
1009 case EndTagToken: | 1013 case EndTagToken: |
1010 switch p.tok.DataAtom { | 1014 switch p.tok.DataAtom { |
1011 case a.Body: | 1015 case a.Body: |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 consumed := false | 2008 consumed := false |
2005 for !consumed { | 2009 for !consumed { |
2006 if p.inForeignContent() { | 2010 if p.inForeignContent() { |
2007 consumed = parseForeignContent(p) | 2011 consumed = parseForeignContent(p) |
2008 } else { | 2012 } else { |
2009 consumed = p.im(p) | 2013 consumed = p.im(p) |
2010 } | 2014 } |
2011 } | 2015 } |
2012 | 2016 |
2013 if p.hasSelfClosingToken { | 2017 if p.hasSelfClosingToken { |
| 2018 // This is a parse error, but ignore it. |
2014 p.hasSelfClosingToken = false | 2019 p.hasSelfClosingToken = false |
2015 p.parseImpliedToken(EndTagToken, p.tok.DataAtom, p.tok.Data) | |
2016 } | 2020 } |
2017 } | 2021 } |
2018 | 2022 |
2019 func (p *parser) parse() error { | 2023 func (p *parser) parse() error { |
2020 // Iterate until EOF. Any other error will cause an early return. | 2024 // Iterate until EOF. Any other error will cause an early return. |
2021 var err error | 2025 var err error |
2022 for err != io.EOF { | 2026 for err != io.EOF { |
2023 err = p.read() | 2027 err = p.read() |
2024 if err != nil && err != io.EOF { | 2028 if err != nil && err != io.EOF { |
2025 return err | 2029 return err |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 parent = root | 2108 parent = root |
2105 } | 2109 } |
2106 | 2110 |
2107 result := parent.Child | 2111 result := parent.Child |
2108 parent.Child = nil | 2112 parent.Child = nil |
2109 for _, n := range result { | 2113 for _, n := range result { |
2110 n.Parent = nil | 2114 n.Parent = nil |
2111 } | 2115 } |
2112 return result, nil | 2116 return result, nil |
2113 } | 2117 } |
OLD | NEW |