Skip to content

Commit 74fb96d

Browse files
Fixed case-sensitive reference lookup causing unresolved references
Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
1 parent 48119c3 commit 74fb96d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

generator/_scripts/cfdoc_references_resolver.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def load_references(references_file):
2929
ref, url, title = match.groups()
3030
if title is None:
3131
title = ""
32-
references[ref] = (url, title)
32+
# store with lowercase key for case-insensitive matching
33+
references[ref.lower()] = (url, title)
3334

3435
return references
3536

@@ -49,15 +50,16 @@ def replace_link(match):
4950
ref or text
5051
) # if ref is empty use text as ref to support cases like [ref][]
5152

52-
if ref in references:
53-
url, title = references[ref]
53+
ref_lower = ref.lower()
54+
if ref_lower in references:
55+
url, title = references[ref_lower]
5456
if title:
5557
return f'[{text}]({url} "{title}")'
5658
else:
5759
return f"[{text}]({url})"
5860
else:
5961
sys.stderr.write(
60-
f"References {ref} is not found in the _references.md. File: {file_path}"
62+
f"References {ref} is not found in the _references.md. File: {file_path}\n"
6163
)
6264
return match.group(0)
6365

@@ -69,15 +71,16 @@ def replace_link(match):
6971
def replace_function_link(match):
7072
ref = match.group(1)
7173
text = f"{ref}()"
72-
if ref in references:
73-
url, title = references[ref]
74+
ref_lower = ref.lower()
75+
if ref_lower in references:
76+
url, title = references[ref_lower]
7477
if title:
7578
return f'[{text}]({url} "{title}")'
7679
else:
7780
return f"[{text}]({url})"
7881
else:
7982
sys.stderr.write(
80-
f"References {ref} is not found in the _references.md. File: {file_path}"
83+
f"References {ref} is not found in the _references.md. File: {file_path}\n"
8184
)
8285
return match.group(0)
8386

0 commit comments

Comments
 (0)