@@ -158,8 +158,6 @@ def mainLoop(self):
158158
159159
160160for token in self .normalizedTokens ():
161- #print self.phase.__class__.__name__
162- #print token
163161type = token ["type" ]
164162if type == CharactersToken :
165163self .phase .processCharacters (token )
@@ -1360,26 +1358,28 @@ def endTagFormatting(self, token):
13601358name = token ["name" ]
13611359while True :
13621360# Step 1 paragraph 1
1363- afeElement = self .tree .elementInActiveFormattingElements (
1361+ formattingElement = self .tree .elementInActiveFormattingElements (
13641362token ["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 )):
13671367self .parser .parseError ("adoption-agency-1.1" , {"name" :token ["name" ]})
13681368return
13691369
13701370# Step 1 paragraph 2
1371- elif afeElement not in self .tree .openElements :
1371+ elif formattingElement not in self .tree .openElements :
13721372self .parser .parseError ("adoption-agency-1.2" , {"name" :token ["name" ]})
1373- self .tree .activeFormattingElements .remove (afeElement )
1373+ self .tree .activeFormattingElements .remove (formattingElement )
13741374return
13751375
13761376# Step 1 paragraph 3
1377- if afeElement != self .tree .openElements [- 1 ]:
1377+ if formattingElement != self .tree .openElements [- 1 ]:
13781378self .parser .parseError ("adoption-agency-1.3" , {"name" :token ["name" ]})
13791379
13801380# Step 2
13811381# Start of the adoption agency algorithm proper
1382- afeIndex = self .tree .openElements .index (afeElement )
1382+ afeIndex = self .tree .openElements .index (formattingElement )
13831383furthestBlock = None
13841384for element in self .tree .openElements [afeIndex :]:
13851385if (element .nameTuple in
@@ -1390,7 +1390,7 @@ def endTagFormatting(self, token):
13901390# Step 3
13911391if furthestBlock is None :
13921392element = self .tree .openElements .pop ()
1393- while element != afeElement :
1393+ while element != formattingElement :
13941394element = self .tree .openElements .pop ()
13951395self .tree .activeFormattingElements .remove (element )
13961396return
@@ -1405,7 +1405,7 @@ def endTagFormatting(self, token):
14051405# nodes in step 12. We have to ensure that we reinsert nodes after
14061406# the node before the active formatting element. Note the bookmark
14071407# can move in step 7.4
1408- bookmark = self .tree .activeFormattingElements .index (afeElement )
1408+ bookmark = self .tree .activeFormattingElements .index (formattingElement )
14091409
14101410# Step 6
14111411lastNode = node = furthestBlock
@@ -1420,7 +1420,7 @@ def endTagFormatting(self, token):
14201420self .tree .openElements .index (node )- 1 ]
14211421self .tree .openElements .remove (tmpNode )
14221422# Step 6.3
1423- if node == afeElement :
1423+ if node == formattingElement :
14241424break
14251425# Step 6.4
14261426if lastNode == furthestBlock :
@@ -1437,7 +1437,7 @@ def endTagFormatting(self, token):
14371437self .tree .openElements .index (node )]= clone
14381438node = clone
14391439
1440- # Step7 .6
1440+ # Step6 .6
14411441# Remove lastNode from its parents, if any
14421442if lastNode .parent :
14431443lastNode .parent .removeChild (lastNode )
@@ -1455,7 +1455,7 @@ def endTagFormatting(self, token):
14551455commonAncestor .appendChild (lastNode )
14561456
14571457# Step 8
1458- clone = afeElement .cloneNode ()
1458+ clone = formattingElement .cloneNode ()
14591459
14601460# Step 9
14611461furthestBlock .reparentChildren (clone )
@@ -1464,11 +1464,11 @@ def endTagFormatting(self, token):
14641464furthestBlock .appendChild (clone )
14651465
14661466# Step 11
1467- self .tree .activeFormattingElements .remove (afeElement )
1467+ self .tree .activeFormattingElements .remove (formattingElement )
14681468self .tree .activeFormattingElements .insert (bookmark ,clone )
14691469
14701470# Step 12
1471- self .tree .openElements .remove (afeElement )
1471+ self .tree .openElements .remove (formattingElement )
14721472self .tree .openElements .insert (
14731473self .tree .openElements .index (furthestBlock )+ 1 ,clone )
14741474