bibclean🔗
bibclean is a linter and formatter for BibTeX files. It rewrites a .bib
file into a canonical style and reports what it cannot rewrite, so that a
bibliography stays readable in review and builds without surprises with pybtex
and sphinxcontrib-bibtex.
one canonical style, described in Canonical format;
fifteen rules, described in Rules;
configuration discovered from
pyproject.toml,bibclean.tomlor.bibclean.toml, described in Configuration;comments,
@stringmacros,@preambleblocks and unknown entry types are preserved, and a file with a block that cannot be parsed is reported and never rewritten.
Install🔗
pip install bibclean
uv tool install bibclean
pip install git+https://github.com/mscheltienne/bibclean
Quick start🔗
bibclean check reports violations without touching the files, bibclean fix
rewrites them in place. Both accept any number of files.
bibclean check doc/*.bib
bibclean fix doc/references.bib
doc/references.bib:14:3: strip-field field 'abstract' is not kept for @article [*]
doc/references.bib:27:1: duplicate-key cite key 'smith2020' is already defined as 'Smith2020' at line 3
doc/references.bib: file is not formatted, run `bibclean fix` [*]
Found 3 violations (2 fixable).
The lines marked [*] are the ones bibclean fix resolves. See Command-line
for the options, the exit codes and the output format.
pre-commit🔗
Two pre-commit hooks are available: bibclean-check reports and never writes,
bibclean-fix rewrites and exits with a non-zero code when it did.
repos:
- repo: https://github.com/mscheltienne/bibclean
rev: 1.0.0
hooks:
- id: bibclean-fix
Changelog🔗
The list of changes of each release is in the Changelog.
License🔗
bibclean is licensed under the MIT license. A full copy of the license can
be found on GitHub.