A tool for parsing and cleaning BibTex and BibLaTex files for better LaTex bibliography formatting.
Project description
BibCleaner
BibCleaner is a Python package designed to parse, clean, and format .bib files for better LaTeX bibliography management. It ensures consistency in formatting, validates DOIs, and helps detect missing or incorrect fields. It facilitates integrations between citation management tools such as zotero and latex editor.
Features
Parses .bib files and structures them properly
Cleans and formats author names (handles capitalization, prefixes like "van", "de", etc.)
Ensures proper title capitalization (preserving LaTeX commands)
Customize fields and remove duplicate authors
Detects and fixes formatting issues in pages, DOIs, dates, etc.
Validates DOIs and warns if they are broken
Auto-generates citation keys based on author, title, and year
Categorizes warnings:
- Critical Issues: Missing author, title, year, etc.
- Soft Warnings: Broken DOI, minor inconsistencies
Installation
Install the package using pip:
pip install bibcleaner
Or, clone the repository and install it manually:
git clone https://github.com/harryziyuhe/bibcleaner.git
cd bibcleaner
pip install .
Usage
Basic Usage (CLI)
from bibcleaner import BibCleaner
cleaner = BibCleaner("references.bib")
cleaner.process()
cleaner.save_as_bib("cleaned_references.bib")
Example Input & Output
Example .bib File (Before Cleaning)
@article{einstein1923,
author = "albert einstein",
title = "the theory of relativity",
journal = "journal of physics",
year = "1923",
doi = "10.1000/xyz123"
}
Cleaned Output
@article{Einstein_Theory_1923,
author = {Albert Einstein},
title = {The Theory of Relativity},
journal = {Journal of Physics},
year = {1923},
doi = {10.1000/xyz123}
}
Warning Output
Critical Issues Found:
Missing required field 'author' in @article{sample2024}
Soft Warnings:
DOI '10.1000/broken' in @article{sample2023} may be broken (HTTP 404).
Advanced Features
Cleaning Options
You can specify which fields to keep when cleaning. Example:
keep_fields = {
"article": ["author", "title", "journal", "year"],
"book": ["author", "title", "publisher", "year"]
}
cleaner = BibCleaner("references.bib", keep_fields)
cleaner.process()
Export to JSON
cleaner.save_as_json("cleaned_references.json")
License
This project is licensed under the MIT License.
See LICENSE for details.
Contact
For suggestions or issues, feel free to open an issue on GitHub or contact zih028@ucsd.edu
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cleanbib-0.1.1.tar.gz.
File metadata
- Download URL: cleanbib-0.1.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b44af4cf6717509b6743b862077ab0bf9c6cd5a278bb59191b698beec8476d09
|
|
| MD5 |
b7b64ae0b55a6132548367549da80868
|
|
| BLAKE2b-256 |
4aa4bd157bb318a966074f41f56cce3ff0e7cfdc1fdfd19716b4f44ea5333a30
|
File details
Details for the file cleanbib-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cleanbib-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac8e1048c5b98e29b159364757b38f4c8a4061959c2ed12331889b4b036db345
|
|
| MD5 |
a14b0e5c9c7dbce42ce00770bc7fd1db
|
|
| BLAKE2b-256 |
141b88d298e2a2a96fe66837510630f857cc86cae28eb5eadfbbe7d6b903f405
|