aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@gmail.com>2016-03-17 18:14:06 +0100
committerDmitry Shachnev <mitya57@gmail.com>2016-03-17 18:14:06 +0100
commit803ab63609d6a148b01d6afc12f841501a5fd84c (patch)
tree7ebeec737ba40971295aa31b49ca97cb5aef65c9
parent6a1b408f82d6c7e59730a4641554bdcab492eb21 (diff)
downloadmarkdown-803ab63609d6a148b01d6afc12f841501a5fd84c.tar.gz
markdown-803ab63609d6a148b01d6afc12f841501a5fd84c.tar.bz2
markdown-803ab63609d6a148b01d6afc12f841501a5fd84c.zip
toc: Remove children from header element after iterating
Removing items while iterating can result in wrong behavior. Refs #461.
-rw-r--r--markdown/extensions/toc.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py
index b3cf898..56db33c 100644
--- a/markdown/extensions/toc.py
+++ b/markdown/extensions/toc.py
@@ -180,7 +180,8 @@ class TocTreeprocessor(Treeprocessor):
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):