Skip to content

Commit

Permalink
toc: Remove children from header element after iterating
Browse files Browse the repository at this point in the history
Removing items while iterating can result in wrong behavior. Refs Python-Markdown#461.
  • Loading branch information
mitya57 committed Mar 17, 2016
1 parent 6a1b408 commit 803ab63
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion markdown/extensions/toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def add_anchor(self, c, elem_id): # @ReservedAssignment
c.text = ""
for elem in c:
anchor.append(elem)
c.remove(elem)
while c:
c.remove(c[0])
c.append(anchor)

def add_permalink(self, c, elem_id):
Expand Down

0 comments on commit 803ab63

Please sign in to comment.