Skip to content

Use case sensitive entry type #453

Open

Description

@claell

Is your feature request related to a problem? Please describe.
Creating an entry with entry = bibtexparser.model.Entry(entry_type, key, fields) won't preserve the case for the entry_type. If I use Article, it gets converted to article, etc.

This is not so nice, as other software will then change the case again when I use it.

Describe the solution you'd like
Ability to preserve the given case.

Use cases
Compatibility with other software, don't mess up git diffs.

Describe alternatives you've considered
Manually changing; using other software for it.

Remaining Questions (Optional)
Please tick all that apply:

  • I would be willing to contribute a PR to fix this issue.
  • This issue is a blocker, I'd be grateful for an early fix.

Activity

  1. claell commented on Jan 25, 2024

    @claell
    ContributorAuthor

    Possibly, there also is a way to do that, which I don't know of, yet.

  2. MiWeiss commented on Jan 25, 2024

    @MiWeiss
    Collaborator

    I confirm there's no way to do this yet.

    The usecase is certainty a valid one, I'm happy to take this into our backlog. However, it should be accompanied by a "KeysToLowercase" middleware to also allow use cases where keys are assumed to be lowercase (which is helpful, e.g. when querying for specific blocks or keys).

    Help wanted: Anyone, please volunteer if you'd be willing to implement this feature. Note: The implementation will require some further refinement (e.g. how to define duplicate keys). Thus, make sure to first continue the discussion here before starting with implementing this feature.

  3. claell commented on Jan 26, 2024

    @claell
    ContributorAuthor

    I noticed that this is not a problem, when just creating an entry and writing it. However, when reading a file with case-sensitive entry types, modifying it and saving again, then it results in lower case entry types.

  4. claell commented on Jan 26, 2024

    @claell
    ContributorAuthor

    This allows a manual workaround for now. After loading the file, I'll loop over the entries and manually replace the entry_type with its uppercase version before writing again.

  5. claell commented on Jul 16, 2026

    @claell
    ContributorAuthor

    I opened draft PR #570. It preserves source entry-type spelling by default and adds an explicit NormalizeEntryTypes middleware for callers that want lowercase normalization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions