Skip to content

Commit

Permalink
feat: Deduplicate index entries
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-richards committed Oct 26, 2023
1 parent 0398729 commit 49e5d87
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions xml2rfc/writers/preptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,13 @@ def index_sort(letters):

# done defining helpers, resume back_insert_index() flow
if self.index_entries and self.root.get('indexInclude') == 'true':
# remove duplicate entries
entries = {}
for entry in self.index_entries:
uniq_key = (entry.item, entry.anchor)
entries.setdefault(uniq_key, entry) # keeps only the first for each key
self.index_entries = list(entries.values())
#
index = self.element('section', numbered='false', toc='include')
name = self.element('name')
name.text = 'Index'
Expand Down

0 comments on commit 49e5d87

Please sign in to comment.