Also shorten unused IDs when --shorten-ids is specified

(previously unreferenced IDs were simply ignored)
This commit is contained in:
Eduard Braun 2016-08-14 17:03:37 +02:00
parent df142a2f22
commit ac82d2e52b

View file

@ -663,6 +663,9 @@ def shortenIDs(doc, prefix, unprotectedElements=None):
idList.sort(reverse=True)
idList = [rid for count, rid in idList]
# Add unreferenced IDs to end of idList in arbitrary order
idList.extend([rid for rid in unprotectedElements if not rid in idList])
curIdNum = 1
for rid in idList:
@ -713,7 +716,9 @@ def renameID(doc, idFrom, idTo, identifiedElements, referencedIDs):
del identifiedElements[idFrom]
identifiedElements[idTo] = definingNode
referringNodes = referencedIDs[idFrom]
# Update references to renamed node
referringNodes = referencedIDs.get(idFrom)
if referringNodes is not None:
# Look for the idFrom ID name in each of the referencing elements,
# exactly like findReferencedElements would.