python-bibtexparser icon indicating copy to clipboard operation
python-bibtexparser copied to clipboard

Use case sensitive entry type

Open claell opened this issue 1 year ago • 4 comments

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.

claell avatar Jan 25 '24 18:01 claell

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

claell avatar Jan 25 '24 18:01 claell

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.

MiWeiss avatar Jan 25 '24 20:01 MiWeiss

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.

claell avatar Jan 26 '24 16:01 claell

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.

claell avatar Jan 26 '24 17:01 claell