From b954d4e3336bd5c8512313c131eb20ebb3e04732 Mon Sep 17 00:00:00 2001 From: Kunpei Sakai Date: Fri, 8 Nov 2019 23:23:55 +0900 Subject: [PATCH] html: add Main support This follows up on golang.org/cl/205617 Change-Id: Ic4a232c40a69bcd3ba35abdd36bce933f35248ea Reviewed-on: https://go-review.googlesource.com/c/net/+/206117 Run-TryBot: Kunpei Sakai TryBot-Result: Gobot Gobot Reviewed-by: Nigel Tao --- html/parse.go | 4 +-- html/testdata/webkit/main-element.dat | 46 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 html/testdata/webkit/main-element.dat diff --git a/html/parse.go b/html/parse.go index 0ff15ff1..6ab1e487 100644 --- a/html/parse.go +++ b/html/parse.go @@ -881,7 +881,7 @@ func inBodyIM(p *parser) bool { p.addElement() p.im = inFramesetIM return true - case a.Address, a.Article, a.Aside, a.Blockquote, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Menu, a.Nav, a.Ol, a.P, a.Section, a.Summary, a.Ul: + case a.Address, a.Article, a.Aside, a.Blockquote, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Main, a.Menu, a.Nav, a.Ol, a.P, a.Section, a.Summary, a.Ul: p.popUntil(buttonScope, a.P) p.addElement() case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6: @@ -1137,7 +1137,7 @@ func inBodyIM(p *parser) bool { return false } return true - case a.Address, a.Article, a.Aside, a.Blockquote, a.Button, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Listing, a.Menu, a.Nav, a.Ol, a.Pre, a.Section, a.Summary, a.Ul: + case a.Address, a.Article, a.Aside, a.Blockquote, a.Button, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Listing, a.Main, a.Menu, a.Nav, a.Ol, a.Pre, a.Section, a.Summary, a.Ul: p.popUntil(defaultScope, p.tok.DataAtom) case a.Form: if p.oe.contains(a.Template) { diff --git a/html/testdata/webkit/main-element.dat b/html/testdata/webkit/main-element.dat new file mode 100644 index 00000000..4b103bb0 --- /dev/null +++ b/html/testdata/webkit/main-element.dat @@ -0,0 +1,46 @@ +#data +

foo

bar

baz +#errors +(1,36): expected-closing-tag-but-got-eof +#document +| +| +| +| +|

+| "foo" +|

+| "bar" +|

+| "baz" + +#data +

foo

bar +#errors +#document +| +| +| +| +|
+|

+| "foo" +| "bar" + +#data +xxx
+#errors + * (1,42) unexpected HTML-like start tag token in foreign content + * (1,42) unexpected end of file +#document +| +| +| +| +| "xxx" +| +| +| +| +| +|