Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use seen_ids instead of XPath to find existing IDs
h/t @felixfontein

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed May 17, 2017
1 parent 83354b7 commit 7c68969
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nikola/filters.py
Expand Up @@ -479,10 +479,11 @@ def deduplicate_ids(data, top_classes=None):
off = offending_elements[-2::-1]
for e in off:
new_id = i
while doc.xpath('//*[@id="{}"]'.format(new_id)):
while new_id in seen_ids:
new_id = '{0}-{1}'.format(i, counter)
counter += 1
e.attrib['id'] = new_id
seen_ids.add(new_id)
# Find headerlinks that we can fix.
headerlinks = e.find_class('headerlink')
for hl in headerlinks:
Expand Down

0 comments on commit 7c68969

Please sign in to comment.