Skip to content

Commit 33af06a

Browse files
committed
Make DOM work right with namespaces, probably
1 parent 3daab98 commit 33af06a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/html5lib/html5parser.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,16 +1262,18 @@ def startTagOther(self, token):
12621262
self.tree.insertElement(token)
12631263

12641264
def endTagP(self, token):
1265-
if self.tree.elementInScope("p"):
1266-
self.tree.generateImpliedEndTags("p")
1267-
if self.tree.openElements[-1].name != "p":
1265+
1266+
if not self.tree.elementInScope("p"):
1267+
self.startTagCloseP(impliedTagToken("p", "StartTag"))
12681268
self.parser.parseError("unexpected-end-tag", {"name": "p"})
1269-
if self.tree.elementInScope("p"):
1270-
while self.tree.elementInScope("p"):
1271-
self.tree.openElements.pop()
1269+
self.endTagP(impliedTagToken("p", "EndTag"))
12721270
else:
1273-
self.startTagCloseP(impliedTagToken("p", "StartTag"))
1274-
self.endTagP(impliedTagToken("p"))
1271+
self.tree.generateImpliedEndTags("p")
1272+
if self.tree.openElements[-1].name != "p":
1273+
self.parser.parseError("unexpected-end-tag", {"name": "p"})
1274+
node = self.tree.openElements.pop()
1275+
while node.name != "p":
1276+
node = self.tree.openElements.pop()
12751277

12761278
def endTagBody(self, token):
12771279
# XXX Need to take open <p> tags into account here. We shouldn't imply

0 commit comments

Comments
 (0)