@@ -953,7 +953,7 @@ def processCharacters(self, token):
953
953
# do it for space characters.
954
954
self .tree .reconstructActiveFormattingElements ()
955
955
self .tree .insertText (token ["data" ])
956
- self .framesetOK = False
956
+ self .parser . framesetOK = False
957
957
958
958
#This matches the current spec but may not match the real world
959
959
def processSpaceCharacters (self , token ):
@@ -1262,16 +1262,17 @@ def startTagOther(self, token):
1262
1262
self .tree .insertElement (token )
1263
1263
1264
1264
def endTagP (self , token ):
1265
- if self .tree .elementInScope ("p" ):
1266
- self .tree .generateImpliedEndTags ("p" )
1267
- if self .tree .openElements [- 1 ].name != "p" :
1265
+ if not self .tree .elementInScope ("p" ):
1266
+ self .startTagCloseP (impliedTagToken ("p" , "StartTag" ))
1268
1267
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 ()
1268
+ self .endTagP (impliedTagToken ("p" , "EndTag" ))
1272
1269
else :
1273
- self .startTagCloseP (impliedTagToken ("p" , "StartTag" ))
1274
- self .endTagP (impliedTagToken ("p" ))
1270
+ self .tree .generateImpliedEndTags ("p" )
1271
+ if self .tree .openElements [- 1 ].name != "p" :
1272
+ self .parser .parseError ("unexpected-end-tag" , {"name" : "p" })
1273
+ node = self .tree .openElements .pop ()
1274
+ while node .name != "p" :
1275
+ node = self .tree .openElements .pop ()
1275
1276
1276
1277
def endTagBody (self , token ):
1277
1278
# XXX Need to take open <p> tags into account here. We shouldn't imply
0 commit comments