diff --git a/xml2rfc/writers/preptool.py b/xml2rfc/writers/preptool.py index 809446fa..c5ffb908 100644 --- a/xml2rfc/writers/preptool.py +++ b/xml2rfc/writers/preptool.py @@ -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'