@@ -158,8 +158,6 @@ def mainLoop(self):
158
158
159
159
160
160
for token in self .normalizedTokens ():
161
- #print self.phase.__class__.__name__
162
- #print token
163
161
type = token ["type" ]
164
162
if type == CharactersToken :
165
163
self .phase .processCharacters (token )
@@ -1360,26 +1358,28 @@ def endTagFormatting(self, token):
1360
1358
name = token ["name" ]
1361
1359
while True :
1362
1360
# Step 1 paragraph 1
1363
- afeElement = self .tree .elementInActiveFormattingElements (
1361
+ formattingElement = self .tree .elementInActiveFormattingElements (
1364
1362
token ["name" ])
1365
- if not afeElement or (afeElement in self .tree .openElements and
1366
- not self .tree .elementInScope (afeElement .name )):
1363
+ if not formattingElement or (formattingElement in
1364
+ self .tree .openElements and
1365
+ not self .tree .elementInScope (
1366
+ formattingElement .name )):
1367
1367
self .parser .parseError ("adoption-agency-1.1" , {"name" : token ["name" ]})
1368
1368
return
1369
1369
1370
1370
# Step 1 paragraph 2
1371
- elif afeElement not in self .tree .openElements :
1371
+ elif formattingElement not in self .tree .openElements :
1372
1372
self .parser .parseError ("adoption-agency-1.2" , {"name" : token ["name" ]})
1373
- self .tree .activeFormattingElements .remove (afeElement )
1373
+ self .tree .activeFormattingElements .remove (formattingElement )
1374
1374
return
1375
1375
1376
1376
# Step 1 paragraph 3
1377
- if afeElement != self .tree .openElements [- 1 ]:
1377
+ if formattingElement != self .tree .openElements [- 1 ]:
1378
1378
self .parser .parseError ("adoption-agency-1.3" , {"name" : token ["name" ]})
1379
1379
1380
1380
# Step 2
1381
1381
# Start of the adoption agency algorithm proper
1382
- afeIndex = self .tree .openElements .index (afeElement )
1382
+ afeIndex = self .tree .openElements .index (formattingElement )
1383
1383
furthestBlock = None
1384
1384
for element in self .tree .openElements [afeIndex :]:
1385
1385
if (element .nameTuple in
@@ -1390,7 +1390,7 @@ def endTagFormatting(self, token):
1390
1390
# Step 3
1391
1391
if furthestBlock is None :
1392
1392
element = self .tree .openElements .pop ()
1393
- while element != afeElement :
1393
+ while element != formattingElement :
1394
1394
element = self .tree .openElements .pop ()
1395
1395
self .tree .activeFormattingElements .remove (element )
1396
1396
return
@@ -1405,7 +1405,7 @@ def endTagFormatting(self, token):
1405
1405
# nodes in step 12. We have to ensure that we reinsert nodes after
1406
1406
# the node before the active formatting element. Note the bookmark
1407
1407
# can move in step 7.4
1408
- bookmark = self .tree .activeFormattingElements .index (afeElement )
1408
+ bookmark = self .tree .activeFormattingElements .index (formattingElement )
1409
1409
1410
1410
# Step 6
1411
1411
lastNode = node = furthestBlock
@@ -1420,7 +1420,7 @@ def endTagFormatting(self, token):
1420
1420
self .tree .openElements .index (node )- 1 ]
1421
1421
self .tree .openElements .remove (tmpNode )
1422
1422
# Step 6.3
1423
- if node == afeElement :
1423
+ if node == formattingElement :
1424
1424
break
1425
1425
# Step 6.4
1426
1426
if lastNode == furthestBlock :
@@ -1437,7 +1437,7 @@ def endTagFormatting(self, token):
1437
1437
self .tree .openElements .index (node )] = clone
1438
1438
node = clone
1439
1439
1440
- # Step 7 .6
1440
+ # Step 6 .6
1441
1441
# Remove lastNode from its parents, if any
1442
1442
if lastNode .parent :
1443
1443
lastNode .parent .removeChild (lastNode )
@@ -1455,7 +1455,7 @@ def endTagFormatting(self, token):
1455
1455
commonAncestor .appendChild (lastNode )
1456
1456
1457
1457
# Step 8
1458
- clone = afeElement .cloneNode ()
1458
+ clone = formattingElement .cloneNode ()
1459
1459
1460
1460
# Step 9
1461
1461
furthestBlock .reparentChildren (clone )
@@ -1464,11 +1464,11 @@ def endTagFormatting(self, token):
1464
1464
furthestBlock .appendChild (clone )
1465
1465
1466
1466
# Step 11
1467
- self .tree .activeFormattingElements .remove (afeElement )
1467
+ self .tree .activeFormattingElements .remove (formattingElement )
1468
1468
self .tree .activeFormattingElements .insert (bookmark , clone )
1469
1469
1470
1470
# Step 12
1471
- self .tree .openElements .remove (afeElement )
1471
+ self .tree .openElements .remove (formattingElement )
1472
1472
self .tree .openElements .insert (
1473
1473
self .tree .openElements .index (furthestBlock ) + 1 , clone )
1474
1474
0 commit comments