@@ -305,9 +305,28 @@ def missing_reference(app: Sphinx, env: BuildEnvironment, node: pending_xref,
305305 to_try .append ((inventories .named_inventory [setname ], full_qualified_name ))
306306 for inventory , target in to_try :
307307 for objtype in objtypes :
308- if objtype not in inventory or target not in inventory [objtype ]:
308+ if objtype not in inventory :
309+ # Continue if there's nothing of this kind in the inventory
309310 continue
310- proj , version , uri , dispname = inventory [objtype ][target ]
311+ if target in inventory [objtype ]:
312+ # Case sensitive match, use it
313+ proj , version , uri , dispname = inventory [objtype ][target ]
314+ elif objtype == 'std:term' :
315+ # Check for potential case insensitive matches for terms only
316+ target_lower = target .lower ()
317+ insensitive_matches = list (filter (lambda k : k .lower () == target_lower ,
318+ inventory [objtype ].keys ()))
319+ if insensitive_matches :
320+ proj , version , uri , dispname = inventory [objtype ][insensitive_matches [0 ]]
321+ else :
322+ # No case insensitive match either, continue to the next candidate
323+ continue
324+ else :
325+ # Could reach here if we're not a term but have a case insensitive match.
326+ # This is a fix for terms specifically, but potentially should apply to
327+ # other types.
328+ continue
329+
311330 if '://' not in uri and node .get ('refdoc' ):
312331 # get correct path in case of subdirectories
313332 uri = path .join (relative_path (node ['refdoc' ], '.' ), uri )
0 commit comments