name: bibtex-janitor description: Clean and standardize .bib files for AER/QJE economics journal submissions
BibTeX Janitor
Cleans and standardizes BibTeX files for economics journal submissions (AER, QJE, etc.).
Usage
/clean-bib path/to/references.bib
What it does
- Journal Names: Standardizes to full formal names (e.g., 'JPE' → 'Journal of Political Economy')
- Title Casing: Applies Title Case and wraps acronyms in braces ({GDP}, {USA})
- Field Pruning: Removes abstract, keywords, issn, file, mendeley-groups
- URL/DOI: Keeps only for @techreport/@unpublished, removes from @article
- NBER Format: Ensures @techreport with proper institution field
- Validation: Checks for missing mandatory fields
Requirements
pip install bibtexparser
Implementation
Core Functions
load_bib(filepath): Load and parse BibTeX files using bibtexparsersave_bib(bib_db): Convert parsed database back to properly formatted BibTeXapply_title_case(entry): Apply title case with special handling for acronyms and proper namesstandardize_journal_names(entry): Map journal abbreviations to full formal namesprune_fields(entry): Remove metadata fields (abstract, keywords, file, etc.)handle_url_doi(entry): Conditionally keep URLs only for @techreport/@unpublished typesensure_nber_format(entry): Convert NBER papers to @techreport with proper institution fieldvalidate_entry(entry): Check for required fields by entry typeclean_entry(entry): Orchestrate all cleaning operations on a single entryclean_bib_file(filepath, in_place=False): Apply all cleaning to entire file
Supported Entry Types
@article: Journal papers (removes URLs, standardizes journal names)@techreport: Working papers and technical reports (preserves URLs)@book: Books (validates publisher field)@inproceedings/@incollection: Conference papers (validates booktitle field)