Skip to content

🐛 Resolve @string references case-insensitively#559

Merged
MiWeiss merged 1 commit into
mainfrom
fix/541-case-insensitive-string-resolution
Jun 12, 2026
Merged

🐛 Resolve @string references case-insensitively#559
MiWeiss merged 1 commit into
mainfrom
fix/541-case-insensitive-string-resolution

Conversation

@MiWeiss

@MiWeiss MiWeiss commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Fixes #541

BibTeX downcases macro names when reading them, so @string keys are case-insensitive (e.g. month = JAN resolves against the style-defined jan). ResolveStringReferencesMiddleware did an exact, case-sensitive lookup in library.strings_dict, so such references were silently left unresolved.

Changes

  • Build a casefolded {key.lower(): value} lookup once per transform and match field values via field.value.lower(). Side benefit: avoids calling strings_dict (which copies the dict) up to twice per field.
  • If two @string blocks differ only in case, the later definition wins, matching BibTeX redefinition semantics.
  • Added a test covering both directions (uppercase reference to lowercase definition and vice versa).

Out of scope

Library duplicate-key detection still compares string keys case-sensitively (@string{jan=...} + @string{JAN=...} is not flagged). That changes public Library behavior and deserves its own discussion/PR.

🤖 Generated with Claude Code

BibTeX treats string (macro) keys as case-insensitive, but
ResolveStringReferencesMiddleware did an exact dict lookup, so
e.g. `month = JAN` did not resolve against `@string{jan = ...}`.

Build a casefolded lookup once per transform; on keys differing
only in case, the later definition wins, matching BibTeX
redefinition semantics.

Fixes #541

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@MiWeiss MiWeiss merged commit aa37698 into main Jun 12, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ResolveStringReferencesMiddleware is case-sensitive, but BibTeX string keys are case-insensitive

1 participant