Permalink
Browse files

Try new IDs until a free one is found

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information...
1 parent 81c337c commit 79a391412dd97a42683a9f93f21d62d6ad0d06dc @Kwpolska Kwpolska committed May 14, 2017
Showing with 4 additions and 2 deletions.
  1. +4 −2 nikola/filters.py
View
@@ -460,9 +460,11 @@ def deduplicate_ids(data):
offending_elements = doc.xpath('//*[@id="{}"]'.format(i))
counter = 2
for e in offending_elements[1::-1]:
- new_id = '{0}-{1}'.format(i, counter)
+ new_id = i
+ while doc.xpath('//*[@id="{}"]'.format(new_id)):
+ new_id = '{0}-{1}'.format(i, counter)
+ counter += 1
e.attrib['id'] = new_id
- counter += 1
# Find headerlinks that we can fix.
headerlinks = e.find_class('headerlink')
for hl in headerlinks:

0 comments on commit 79a3914

Please sign in to comment.