mirror of
https://github.com/golang/go
synced 2024-11-21 23:44:39 -07:00
html: stop at scope marker node when generating implied </a> tags
A <a> tag generates implied end tags for any open <a> elements. But it shouldn't do that when it is inside a table cell the the open <a> is outside the table. So stop the search for an open <a> when we reach a scope marker node. Pass tests1.dat, test 78: <a href="blah">aba<table><tr><td><a href="foo">br</td></tr>x</table>aoe | <html> | <head> | <body> | <a> | href="blah" | "abax" | <table> | <tbody> | <tr> | <td> | <a> | href="foo" | "br" | "aoe" Also pass test 79: <table><a href="blah">aba<tr><td><a href="foo">br</td></tr>x</table>aoe R=nigeltao CC=golang-dev https://golang.org/cl/5320063
This commit is contained in:
parent
90b76c0f3e
commit
22ee5ae25a
@ -135,6 +135,8 @@ func (s *nodeStack) remove(n *Node) {
|
|||||||
*s = (*s)[:j]
|
*s = (*s)[:j]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(nigeltao): forTag no longer used. Should it be deleted?
|
||||||
|
|
||||||
// forTag returns the top-most element node with the given tag.
|
// forTag returns the top-most element node with the given tag.
|
||||||
func (s *nodeStack) forTag(tag string) *Node {
|
func (s *nodeStack) forTag(tag string) *Node {
|
||||||
for i := len(*s) - 1; i >= 0; i-- {
|
for i := len(*s) - 1; i >= 0; i-- {
|
||||||
|
@ -553,10 +553,13 @@ func inBodyIM(p *parser) (insertionMode, bool) {
|
|||||||
}
|
}
|
||||||
p.addElement(p.tok.Data, p.tok.Attr)
|
p.addElement(p.tok.Data, p.tok.Attr)
|
||||||
case "a":
|
case "a":
|
||||||
if n := p.afe.forTag("a"); n != nil {
|
for i := len(p.afe) - 1; i >= 0 && p.afe[i].Type != scopeMarkerNode; i-- {
|
||||||
p.inBodyEndTagFormatting("a")
|
if n := p.afe[i]; n.Type == ElementNode && n.Data == "a" {
|
||||||
p.oe.remove(n)
|
p.inBodyEndTagFormatting("a")
|
||||||
p.afe.remove(n)
|
p.oe.remove(n)
|
||||||
|
p.afe.remove(n)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p.reconstructActiveFormattingElements()
|
p.reconstructActiveFormattingElements()
|
||||||
p.addFormattingElement(p.tok.Data, p.tok.Attr)
|
p.addFormattingElement(p.tok.Data, p.tok.Attr)
|
||||||
|
@ -132,7 +132,7 @@ func TestParser(t *testing.T) {
|
|||||||
rc := make(chan io.Reader)
|
rc := make(chan io.Reader)
|
||||||
go readDat(filename, rc)
|
go readDat(filename, rc)
|
||||||
// TODO(nigeltao): Process all test cases, not just a subset.
|
// TODO(nigeltao): Process all test cases, not just a subset.
|
||||||
for i := 0; i < 78; i++ {
|
for i := 0; i < 80; i++ {
|
||||||
// Parse the #data section.
|
// Parse the #data section.
|
||||||
b, err := ioutil.ReadAll(<-rc)
|
b, err := ioutil.ReadAll(<-rc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user