diff options
author | Dmitry Shachnev <mitya57@gmail.com> | 2016-03-17 18:14:06 +0100 |
---|---|---|
committer | Dmitry Shachnev <mitya57@gmail.com> | 2016-03-17 18:14:06 +0100 |
commit | 803ab63609d6a148b01d6afc12f841501a5fd84c (patch) | |
tree | 7ebeec737ba40971295aa31b49ca97cb5aef65c9 | |
parent | 6a1b408f82d6c7e59730a4641554bdcab492eb21 (diff) | |
download | markdown-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.py | 3 |
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): |