Skip to content

Commit 320dbc3

Browse files
committed
Fix issue 126 by making reconstructing active formatting elements always work with positive indicies
1 parent 468db49 commit 320dbc3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/html5lib/treebuilders/_base.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,18 @@ def reconstructActiveFormattingElements(self):
157157
return
158158

159159
# Step 2 and step 3: we start with the last element. So i is -1.
160-
i = -1
160+
i = len(self.activeFormattingElements) - 1
161161
entry = self.activeFormattingElements[i]
162162
if entry == Marker or entry in self.openElements:
163163
return
164164

165165
# Step 6
166166
while entry != Marker and entry not in self.openElements:
167-
i -= 1
168-
if i < 0:
169-
# Step 4: at this point we need to jump to step 8.
170-
# So we reset the index to 0 and break
171-
i += 1
167+
if i == 0:
168+
#This will be reset to 0 below
169+
i = -1
172170
break
171+
i -= 1
173172
# Step 5: let entry be one earlier in the list.
174173
entry = self.activeFormattingElements[i]
175174

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