Skip to content

Make string reference expansion opt-in #590

Description

@claell

Problem

The default parse stack applies ResolveStringReferencesMiddleware. An entry such as journal = journalName therefore becomes the current literal value of @string{journalName = ...}. Writing the parsed library emits the expanded value and loses the relationship to the macro definition.

That is not merely formatting normalization: later edits to the @string definition no longer update the entry, and a parse/write cycle creates many duplicated literals. The original reference cannot be reconstructed reliably from the expanded text.

Proposed default

Remove ResolveStringReferencesMiddleware from the default parse stack so references remain references. Keep the middleware public and document an explicit dereferencing profile:

layers = [
    ResolveStringReferencesMiddleware(),
    RemoveEnclosingMiddleware(),
]

Ordering matters because interpolation must see the original expression before ordinary enclosure removal changes its representation.

Add public-entry-point tests proving both contracts:

  • default parsing and writing retain @string linkage; and
  • callers who explicitly request interpolation receive expanded values.

Compatibility

This is a user-visible default change. Existing users who rely on immediate expanded values must add the middleware explicitly. The alternative is irreversible semantic loss during ordinary parse/write use, so preservation is the safer default for a bibliography codec.

Concatenated expressions and cyclic/unresolved references are related to #396 but are not prerequisites for deciding the default. The initial implementation should use basic references and remain independently reviewable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions