diff options
author | Waylan Limberg <waylan@gmail.com> | 2013-02-22 10:15:08 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2013-02-22 10:15:08 -0500 |
commit | 9aa8224faa79ac1472a70ae6fe6594022c22a2e6 (patch) | |
tree | 54168896d05a09a98b9cccc68225ff3f447b5834 /markdown/extensions | |
parent | 8aa2fc7b5138fd97ded7dd1e70103532a9fd6583 (diff) | |
download | markdown-9aa8224faa79ac1472a70ae6fe6594022c22a2e6.tar.gz markdown-9aa8224faa79ac1472a70ae6fe6594022c22a2e6.tar.bz2 markdown-9aa8224faa79ac1472a70ae6fe6594022c22a2e6.zip |
Change `set.append` -> `set.add` in `headerid.unique`
Fixes #195. This was getting missed because the HeadrerId extension's
reset method was resetting the IDs to a list. However, some third party
extensions may want to call the unique function and it should work as
documented. Interestingly, the TOC extension was using it and passing in
a list as well. All fixed now. Also added a test of the `unique` function
directly so we shouldn't repeat this in the future.
Diffstat (limited to 'markdown/extensions')
-rw-r--r-- | markdown/extensions/headerid.py | 4 | ||||
-rw-r--r-- | markdown/extensions/toc.py | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/markdown/extensions/headerid.py b/markdown/extensions/headerid.py index b6a12e8..cf3df17 100644 --- a/markdown/extensions/headerid.py +++ b/markdown/extensions/headerid.py @@ -101,7 +101,7 @@ def unique(id, ids): id = '%s_%d'% (m.group(1), int(m.group(2))+1) else: id = '%s_%d'% (id, 1) - ids.append(id) + ids.add(id) return id @@ -191,7 +191,7 @@ class HeaderIdExtension (markdown.Extension): md.treeprocessors.add('headerid', self.processor, '>prettify') def reset(self): - self.processor.IDs = [] + self.processor.IDs = set() def makeExtension(configs=None): diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index 7edc0cc..1d6639e 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -127,7 +127,7 @@ class TocTreeprocessor(markdown.treeprocessors.Treeprocessor): self.use_anchors = self.config["anchorlink"] in [1, '1', True, 'True', 'true'] # Get a list of id attributes - used_ids = [] + used_ids = set() for c in doc.getiterator(): if "id" in c.attrib: used_ids.append(c.attrib["id"]) |