Skip to content
Permalink
Browse files
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 7c689694b3285c0d93b17e58ce2e34a851b57379
Showing with 2 additions and 1 deletion.
  1. +2 −1 nikola/filters.py
@@ -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:

0 comments on commit 7c68969

Please sign in to comment.