From 21316e636b46c397f3bb5fba61bd0fc1e5f72047 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Mon, 5 Oct 2026 21:54:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Note=20field=20key=20case=20chan?= =?UTF-8?q?ge=20in=20migration=20guide?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v1 lowercased all field keys, v2 keeps them as written in the .bib file. Show how to get v1 behavior with the NormalizeFieldKeys middleware. Refs #629 --- docs/source/migrate.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/source/migrate.rst b/docs/source/migrate.rst index 9595c27..a4fc816 100644 --- a/docs/source/migrate.rst +++ b/docs/source/migrate.rst @@ -102,6 +102,15 @@ If you need plain dicts as in v1, e.g. to pass entries on to another library, co Field values are whatever the middleware produced (e.g. a list of names after ``SeparateCoAuthors``), not necessarily strings. +Also note that v1 converted all field keys to lowercase, while v2 keeps them as written in the ``.bib`` file +(e.g. ``Title`` stays ``Title``, so ``entry['title']`` fails). To get lowercase keys as in v1, add the ``NormalizeFieldKeys`` middleware: + +.. code-block:: python + + from bibtexparser.middlewares import NormalizeFieldKeys + + library = bibtexparser.parse_file('bibtex.bib', append_middleware=[NormalizeFieldKeys()]) + Similarly, other block types (comments, strings, ...) are now also represented as dedicated :ref:`object types `, but for them, the migration is straight forward and we will not go into detail here.