Skip to main content

Blackref: An Uncompromising BibTeX/BibLaTeX Formatter

CI Coverage Status      Version: 0.2.0 Status: Beta      License: AGPL-3.0 Python: >=3.12,<3.15

blackref is a command-line tool that automatically formats your BibTeX and BibLaTeX files to be consistent, readable, and clean. Inspired by the black code formatter for Python, it enforces a strict, opinionated style, leaving no room for configuration. This ensures that your reference files are always perfectly formatted, allowing you to focus on the content, not the style.

Key Features

  • Consistent Formatting: Automatically formats your entire BibTeX/BibLaTeX file.
  • Entry Sorting: Sorts the entries in your bibliography (e.g., by entry ID).
  • Field Ordering: Arranges the fields within each entry in a consistent, logical order.
  • Smart Encoding: Handles both UTF-8 and LaTeX encoding for specified fields.
  • In-place Modification: Can modify files directly for convenience.
  • Unix Philosophy: Reads from stdin and writes to stdout by default, making it easy to pipe and integrate into scripts.

Usage

Run the package directly with uvx:

uvx blackref my_references.bib

You can also use it with pipes:

cat my_references.bib | uvx blackref > formatted_references.bib

To modify a file directly, use write-back mode:

uvx blackref --write-back my_references.bib

You can specify which fields to sort the entries by. The default is to sort by the BibTeX entry ID (ID).

uvx blackref --sort "author,year" my_references.bib

blackref uses a default order for fields within each entry. You can override this with the --display-order option.

uvx blackref --display-order "author,title,year,journal" my_references.bib

Pre-commit hooks

You can format BibTeX and BibLaTeX files automatically before committing them to git.

repos:
- repo: https://github.com/dvolgyes/blackref
  rev: v0.2.0
  hooks:
  - id: blackref

Complementary Tool: reflint

For linting and checking the semantic content of your reference files (e.g., missing fields, incorrect values), check out the complementary tool, reflint. reflint fixes the content, while blackref fixes the style.

License

blackref is licensed under the AGPL-3.0 License. See the LICENSE.txt file for details.

Metadata

Release files for blackref 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blackref 0.2.1
File Size Uploaded Provenance Actions
blackref-0.2.1.tar.gz 34.6 kB Without provenance Details for blackref-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for blackref 0.2.1
File Interpreter ABI Platform Actions
blackref-0.2.1-py3-none-any.whl Python 3 none any Details for blackref-0.2.1-py3-none-any.whl

Total release size: 52.9 kB

Release files / blackref-0.2.1.tar.gz

Download URL blackref-0.2.1.tar.gz
Size 34.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a3fb3998f3e1e7167018c70ce16caaaa69a0923020e84a254cdf645ceba1fe1b
BLAKE2b-256 checksum
How to use checksums
7fcebfa49c9472fad1b1fdf250c87ea2fbd5d7a105c8ee5cb4517465a2c03696
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / blackref-0.2.1-py3-none-any.whl

Download URL blackref-0.2.1-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98c6d34745549d05c169f44f0c7b61f0f9f15a015eb8486f54697aa9cef092a8
BLAKE2b-256 checksum
How to use checksums
a826ddb56d5e1b01350413a9eba147a5c3f20cbe55271763913309527a62dfef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for blackref 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page