Skip to content

Commit 8904365

Browse files
committed
Start to update AAA. This gets the tests passing.
However, all the comments should be updated.
1 parent a0415f2 commit 8904365

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

html5lib/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@
180180
"adoption-agency-1.3":
181181
_("End tag (%(name)s) violates step 1, "
182182
"paragraph 3 of the adoption agency algorithm."),
183+
"adoption-agency-4.4":
184+
_("End tag (%(name)s) violates step 4, "
185+
"paragraph 4 of the adoption agency algorithm."),
183186
"unexpected-end-tag-treated-as":
184187
_("Unexpected end tag (%(originalName)s). Treated as %(newName)s."),
185188
"no-end-tag":

html5lib/html5parser.py

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,28 +1404,60 @@ def endTagFormatting(self, token):
14041404
# XXX Better parseError messages appreciated.
14051405
name = token["name"]
14061406

1407+
# Step 1
14071408
outerLoopCounter = 0
1409+
1410+
# Step 2
14081411
while outerLoopCounter < 8:
1412+
1413+
# Step 3
14091414
outerLoopCounter += 1
14101415

1411-
# Step 1 paragraph 1
1416+
# Step 4:
1417+
1418+
# Let the formatting element be the last element in
1419+
# the list of active formatting elements that:
1420+
# - is between the end of the list and the last scope
1421+
# marker in the list, if any, or the start of the list
1422+
# otherwise, and
1423+
# - has the same tag name as the token.
14121424
formattingElement = self.tree.elementInActiveFormattingElements(
14131425
token["name"])
14141426
if (not formattingElement or
14151427
(formattingElement in self.tree.openElements and
14161428
not self.tree.elementInScope(formattingElement.name))):
1417-
self.parser.parseError("adoption-agency-1.1", {"name": token["name"]})
1429+
# If there is no such node, then abort these steps
1430+
# and instead act as described in the "any other
1431+
# end tag" entry below.
1432+
self.endTagOther(token)
14181433
return
14191434

1420-
# Step 1 paragraph 2
1435+
# Otherwise, if there is such a node, but that node is
1436+
# not in the stack of open elements, then this is a
1437+
# parse error; remove the element from the list, and
1438+
# abort these steps.
14211439
elif formattingElement not in self.tree.openElements:
14221440
self.parser.parseError("adoption-agency-1.2", {"name": token["name"]})
14231441
self.tree.activeFormattingElements.remove(formattingElement)
14241442
return
1443+
1444+
1445+
# Otherwise, if there is such a node, and that node is
1446+
# also in the stack of open elements, but the element
1447+
# is not in scope, then this is a parse error; ignore
1448+
# the token, and abort these steps.
1449+
elif not self.tree.elementInScope(formattingElement.name):
1450+
self.parser.parseError("adoption-agency-4.4", {"name": token["name"]})
1451+
return
14251452

1426-
# Step 1 paragraph 3
1427-
if formattingElement != self.tree.openElements[-1]:
1428-
self.parser.parseError("adoption-agency-1.3", {"name": token["name"]})
1453+
# Otherwise, there is a formatting element and that
1454+
# element is in the stack and is in scope. If the
1455+
# element is not the current node, this is a parse
1456+
# error. In any case, proceed with the algorithm as
1457+
# written in the following steps.
1458+
else:
1459+
if formattingElement != self.tree.openElements[-1]:
1460+
self.parser.parseError("adoption-agency-1.3", {"name": token["name"]})
14291461

14301462
# Step 2
14311463
# Start of the adoption agency algorithm proper

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy