A small Python program to normalize .bib files.
During my PhD, I've gathered an extensive collection of BibTeX entries in my bibliography. I've observed inconsistencies in the formatting of these entries, which might require manual adjustments depending on the citation style you want to apply. This program is designed to standardize the BibTeX formats and introduce some basic rules for capitalizing titles.
The core of this tool revolves around iterating through entries in a .bib file and applying normalization rules, with a particular focus on title formatting. The capitalize_title function encapsulates the logic for intelligent title capitalization, considering various linguistic and typographic conventions.
- Clone the repository:
git clone git@github.com:jknafou/bibtex-normalizer.git- Navigate to the project directory:
cd bibtex-normalizer/- (Option 1) Install dependencies using Rye:
rye sync
. .venv/bin/activate # .\venv\Scripts\activate on Windows```- (Option 2) Install dependencies using pip on a venv:
python -m venv .venv
.venv/bin/activate # .\venv\Scripts\activate on Windows```
pip install .One shot installation using pip+git on a venv:
Here, skip step 1 & 2 and run the following commands:
python -m venv .venv
.venv/bin/activate # .\venv\Scripts\activate on Windows```
pip install git+https://github.com/jknafou/bibtex-normalizer.gitNormalize a .bib file:
bibtex-normalizer --input <input_file> --output <output_file>To test the program, you can use the provided example file references.bib by running the following command:
bibtex-normalizer- Specify both input and output files:
bibtex-normalizer --input example.bib --output example_normalized.bib- Use default output naming (input filename + "_normalized" suffix):
bibtex-normalizer --input example.bibWe welcome contributions.