Also shorten unused IDs when --shorten-ids is specified
(previously unreferenced IDs were simply ignored)
This commit is contained in:
parent
df142a2f22
commit
ac82d2e52b
1 changed files with 51 additions and 46 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue