Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0a48b2f

Browse files
ambvgsnedders
authored andcommitted
Fix#16: Adoption agency algorithm comments up to date with r7867
1 parentb4a8a6f commit0a48b2f

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

‎html5lib/html5parser.py

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ def endTagHeading(self, token):
13991399

14001400
defendTagFormatting(self,token):
14011401
"""The much-feared adoption agency algorithm"""
1402-
# http://www.whatwg.org/specs/web-apps/current-work/#adoptionAgency
1402+
# http://svn.whatwg.org/webapps/complete.html#adoptionAgency revision 7867
14031403
# XXX Better parseError messages appreciated.
14041404

14051405
# Step 1
@@ -1456,35 +1456,45 @@ def endTagFormatting(self, token):
14561456
ifformattingElement!=self.tree.openElements[-1]:
14571457
self.parser.parseError("adoption-agency-1.3", {"name":token["name"]})
14581458

1459-
# Step 2
1460-
# Start of the adoption agency algorithm proper
1459+
# Step 5:
1460+
1461+
# Let the furthest block be the topmost node in the
1462+
# stack of open elements that is lower in the stack
1463+
# than the formatting element, and is an element in
1464+
# the special category. There might not be one.
14611465
afeIndex=self.tree.openElements.index(formattingElement)
14621466
furthestBlock=None
14631467
forelementinself.tree.openElements[afeIndex:]:
14641468
ifelement.nameTupleinspecialElements:
14651469
furthestBlock=element
14661470
break
1467-
# Step 3
1471+
1472+
# Step 6:
1473+
1474+
# If there is no furthest block, then the UA must
1475+
# first pop all the nodes from the bottom of the stack
1476+
# of open elements, from the current node up to and
1477+
# including the formatting element, then remove the
1478+
# formatting element from the list of active
1479+
# formatting elements, and finally abort these steps.
14681480
iffurthestBlockisNone:
14691481
element=self.tree.openElements.pop()
14701482
whileelement!=formattingElement:
14711483
element=self.tree.openElements.pop()
14721484
self.tree.activeFormattingElements.remove(element)
14731485
return
1474-
commonAncestor=self.tree.openElements[afeIndex-1]
14751486

1476-
# Step 5
1477-
# if furthestBlock.parent:
1478-
# furthestBlock.parent.removeChild(furthestBlock)
1487+
# Step 7
1488+
commonAncestor=self.tree.openElements[afeIndex-1]
14791489

1480-
# Step5
1490+
# Step8:
14811491
# The bookmark is supposed to help us identify where to reinsert
1482-
# nodes in step12. We have to ensure that we reinsert nodes after
1492+
# nodes in step15. We have to ensure that we reinsert nodes after
14831493
# the node before the active formatting element. Note the bookmark
1484-
# can move in step7.4
1494+
# can move in step9.7
14851495
bookmark=self.tree.activeFormattingElements.index(formattingElement)
14861496

1487-
# Step6
1497+
# Step9
14881498
lastNode=node=furthestBlock
14891499
innerLoopCounter=0
14901500

@@ -1497,36 +1507,32 @@ def endTagFormatting(self, token):
14971507
ifnodenotinself.tree.activeFormattingElements:
14981508
self.tree.openElements.remove(node)
14991509
continue
1500-
# Step6.3
1510+
# Step9.6
15011511
ifnode==formattingElement:
15021512
break
1503-
# Step6.4
1513+
# Step9.7
15041514
iflastNode==furthestBlock:
1505-
bookmark= (self.tree.activeFormattingElements.index(node)
1506-
+1)
1507-
# Step 6.5
1508-
# cite = node.parent
1515+
bookmark=self.tree.activeFormattingElements.index(node)+1
1516+
# Step 9.8
15091517
clone=node.cloneNode()
15101518
# Replace node with clone
15111519
self.tree.activeFormattingElements[
15121520
self.tree.activeFormattingElements.index(node)]=clone
15131521
self.tree.openElements[
15141522
self.tree.openElements.index(node)]=clone
15151523
node=clone
1516-
1517-
# Step 6.6
1524+
# Step 9.9
15181525
# Remove lastNode from its parents, if any
15191526
iflastNode.parent:
15201527
lastNode.parent.removeChild(lastNode)
15211528
node.appendChild(lastNode)
1522-
# Step7.7
1529+
# Step9.10
15231530
lastNode=node
1524-
# End of inner loop
15251531

1526-
# Step7
1532+
# Step10
15271533
# Foster parent lastNode if commonAncestor is a
1528-
# table, tbody, tfoot, thead, or tr we need to foster parent the
1529-
# lastNode
1534+
# table, tbody, tfoot, thead, or tr we need to foster
1535+
#parent thelastNode
15301536
iflastNode.parent:
15311537
lastNode.parent.removeChild(lastNode)
15321538

@@ -1536,20 +1542,20 @@ def endTagFormatting(self, token):
15361542
else:
15371543
commonAncestor.appendChild(lastNode)
15381544

1539-
# Step8
1545+
# Step11
15401546
clone=formattingElement.cloneNode()
15411547

1542-
# Step9
1548+
# Step12
15431549
furthestBlock.reparentChildren(clone)
15441550

1545-
# Step10
1551+
# Step13
15461552
furthestBlock.appendChild(clone)
15471553

1548-
# Step11
1554+
# Step14
15491555
self.tree.activeFormattingElements.remove(formattingElement)
15501556
self.tree.activeFormattingElements.insert(bookmark,clone)
15511557

1552-
# Step12
1558+
# Step15
15531559
self.tree.openElements.remove(formattingElement)
15541560
self.tree.openElements.insert(
15551561
self.tree.openElements.index(furthestBlock)+1,clone)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp