From ac6bf4d3edc642b70b82ca2afdec4d22cdc559a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:46:42 +0000 Subject: [PATCH 1/4] Initial plan From 42d5c594e422ded6bd8c60e9962895c58b924b14 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:51:36 +0000 Subject: [PATCH 2/4] Fix Hugo template to handle both string and array references Co-authored-by: LukasWallrich <60155545+LukasWallrich@users.noreply.github.com> --- layouts/glossary/single.html | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/layouts/glossary/single.html b/layouts/glossary/single.html index 370998ebd78..6c3443df9bf 100644 --- a/layouts/glossary/single.html +++ b/layouts/glossary/single.html @@ -192,9 +192,19 @@ {{ end }} {{ if .Params.references }} - {{ $references := delimit .Params.references ", " | len }} - {{ if ne $references 0 }} -
{{ if gt (len .Params.references) 1 }}{{ index (index $dictionary $lang) "references" }}{{ else }}{{ index (index $dictionary $lang) "reference" }}{{ end }}: {{ delimit .Params.references ", " ", & " | markdownify }}
+ {{ $refs := .Params.references }} + {{ $refsIsString := eq (printf "%T" $refs) "string" }} + {{ if $refsIsString }} + {{ if ne $refs "" }} +{{ index (index $dictionary $lang) "references" }}: {{ $refs | markdownify }}
+ {{ end }} + {{ else }} + {{ if gt (len $refs) 0 }} + {{ $firstRef := index $refs 0 }} + {{ if $firstRef }} +{{ if gt (len $refs) 1 }}{{ index (index $dictionary $lang) "references" }}{{ else }}{{ index (index $dictionary $lang) "reference" }}{{ end }}: {{ range $index, $ref := $refs }}{{ if $index }}, {{ end }}{{ $ref }}{{ end }}
+ {{ end }} + {{ end }} {{ end }} {{ end }} From e3b31545b2cc336326d864274a84dc7e7cd08b29 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:55:46 +0000 Subject: [PATCH 3/4] Fix citation pattern to correctly extract keys from \[@key\] format Co-authored-by: LukasWallrich <60155545+LukasWallrich@users.noreply.github.com> --- content/glossary/_create_glossaries.py | 59 +++++++++++++++----------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/content/glossary/_create_glossaries.py b/content/glossary/_create_glossaries.py index 3bd7c7bce80..f937ceb6d05 100755 --- a/content/glossary/_create_glossaries.py +++ b/content/glossary/_create_glossaries.py @@ -47,32 +47,43 @@ def process_references(references_text, apa_lookup, missing_refs_log=None): if not references_text: return [] - citation_pattern = r'\\?\[@([^\\]+)\\?\]' - matches = re.findall(citation_pattern, references_text) - formatted_refs = [] - for match in matches: - # Clean the key: remove markdown formatting, trailing punctuation, etc. - key = match.strip() - original_key = key # Keep for logging - - # Remove markdown formatting - key = re.sub(r'^\*+|\*+$', '', key) # Remove leading/trailing asterisks - key = re.sub(r'^_+|_+$', '', key) # Remove leading/trailing underscores - - # Remove trailing punctuation - key = re.sub(r'[,;:]+$', '', key) - - # Remove trailing digits that look like typos (e.g., "Pownall20210" -> "Pownall2021") - key = re.sub(r'(\d{4})0+$', r'\1', key) - - if key in apa_lookup: - formatted_refs.append(apa_lookup[key]) - else: - # Log missing reference but don't include in output + + # Match [@key] format (Pandoc citations) + # Matches: \[@key\], [@key], \[@key], [@key\] + citation_pattern = r'\\?\[@([^\]\\]+)\\?\]' + matches = re.findall(citation_pattern, references_text) + + if matches: + # Process [@key] format citations + for match in matches: + # Clean the key: remove markdown formatting, trailing punctuation, etc. + key = match.strip() + original_key = key # Keep for logging + + # Remove markdown formatting + key = re.sub(r'^\*+|\*+$', '', key) # Remove leading/trailing asterisks + key = re.sub(r'^_+|_+$', '', key) # Remove leading/trailing underscores + + # Remove trailing punctuation + key = re.sub(r'[,;:]+$', '', key) + + # Remove trailing digits that look like typos (e.g., "Pownall20210" -> "Pownall2021") + key = re.sub(r'(\d{4})0+$', r'\1', key) + + if key in apa_lookup: + formatted_refs.append(apa_lookup[key]) + else: + # Log missing reference but don't include in output + if missing_refs_log is not None: + missing_refs_log.add(original_key) + print(f"Warning: Missing reference key '{original_key}' (cleaned: '{key}') - skipping") + else: + # No citation keys found - log a warning + if references_text.strip(): + print(f"Warning: No citation keys found in: '{references_text[:50]}...'") if missing_refs_log is not None: - missing_refs_log.add(original_key) - print(f"Warning: Missing reference key '{original_key}' (cleaned: '{key}') - skipping") + missing_refs_log.add(f"[NO KEYS]: {references_text[:50]}") return list(dict.fromkeys(formatted_refs)) From 3e0298c22f9a1e750c47ade83e5c6aedac802b40 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:57:08 +0000 Subject: [PATCH 4/4] Address code review feedback - improve readability Co-authored-by: LukasWallrich <60155545+LukasWallrich@users.noreply.github.com> --- content/glossary/_create_glossaries.py | 4 +++- layouts/glossary/single.html | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/content/glossary/_create_glossaries.py b/content/glossary/_create_glossaries.py index f937ceb6d05..e8366d81c16 100755 --- a/content/glossary/_create_glossaries.py +++ b/content/glossary/_create_glossaries.py @@ -50,7 +50,9 @@ def process_references(references_text, apa_lookup, missing_refs_log=None): formatted_refs = [] # Match [@key] format (Pandoc citations) - # Matches: \[@key\], [@key], \[@key], [@key\] + # Pattern handles: \[@key\], [@key], \[@key], [@key\] + # The Google Sheets may have escaped brackets (\[@key\]) from Markdown, + # so we match both escaped and unescaped versions citation_pattern = r'\\?\[@([^\]\\]+)\\?\]' matches = re.findall(citation_pattern, references_text) diff --git a/layouts/glossary/single.html b/layouts/glossary/single.html index 6c3443df9bf..3e1ccbc9c2f 100644 --- a/layouts/glossary/single.html +++ b/layouts/glossary/single.html @@ -202,7 +202,9 @@ {{ if gt (len $refs) 0 }} {{ $firstRef := index $refs 0 }} {{ if $firstRef }} -{{ if gt (len $refs) 1 }}{{ index (index $dictionary $lang) "references" }}{{ else }}{{ index (index $dictionary $lang) "reference" }}{{ end }}: {{ range $index, $ref := $refs }}{{ if $index }}, {{ end }}{{ $ref }}{{ end }}
+ {{ $refLabel := index (index $dictionary $lang) "reference" }} + {{ if gt (len $refs) 1 }}{{ $refLabel = index (index $dictionary $lang) "references" }}{{ end }} +{{ $refLabel }}: {{ range $index, $ref := $refs }}{{ if $index }}, {{ end }}{{ $ref }}{{ end }}
{{ end }} {{ end }} {{ end }}