Metadata-Version: 2.4
Name: bibclean
Version: 1.0.0
Summary: A linter and formatter for BibTeX files.
Author-email: Mathieu Scheltienne <mathieu.scheltienne@gmail.com>
Maintainer-email: Mathieu Scheltienne <mathieu.scheltienne@gmail.com>
License-Expression: MIT
Project-URL: documentation, https://mscheltienne.github.io/bibclean/
Project-URL: homepage, https://github.com/mscheltienne/bibclean
Project-URL: source, https://github.com/mscheltienne/bibclean
Project-URL: tracker, https://github.com/mscheltienne/bibclean/issues
Keywords: bibliography,bibtex,formatter,linter,pre-commit,sphinx
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.2
Dynamic: license-file

[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![codecov](https://codecov.io/gh/mscheltienne/bibclean/branch/main/graph/badge.svg?token=RX2lXKFDUn)](https://codecov.io/gh/mscheltienne/bibclean)
[![tests](https://github.com/mscheltienne/bibclean/actions/workflows/pytest.yaml/badge.svg?branch=main)](https://github.com/mscheltienne/bibclean/actions/workflows/pytest.yaml)
[![doc](https://github.com/mscheltienne/bibclean/actions/workflows/doc.yaml/badge.svg?branch=main)](https://github.com/mscheltienne/bibclean/actions/workflows/doc.yaml)
[![PyPI version](https://badge.fury.io/py/bibclean.svg)](https://badge.fury.io/py/bibclean)
[![Downloads](https://static.pepy.tech/badge/bibclean)](https://pepy.tech/project/bibclean)

# bibclean

A linter and formatter for BibTeX files, available as a command-line tool and as
pre-commit hooks. 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`. Comments, `@string` macros,
`@preamble` blocks and unknown entry types are preserved, and a file with a block
that cannot be parsed is reported and never rewritten.

```bash
pip install bibclean
bibclean check doc/references.bib   # report violations, never write
bibclean fix doc/references.bib     # rewrite it in place
```

With [uv](https://docs.astral.sh/uv/), `uvx bibclean check doc/references.bib` runs
it without installing it. Example output:

```
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).
```

Two pre-commit hooks are available: `bibclean-check` reports and never writes,
`bibclean-fix` rewrites and fails when it did.

```yaml
repos:
  - repo: https://github.com/mscheltienne/bibclean
    rev: 1.0.0
    hooks:
      - id: bibclean-fix
```

The documentation, including the canonical format, the fifteen rules and the
configuration reference, is available
[here](https://mscheltienne.github.io/bibclean/dev/index.html).
