Skip to main content

An uncompromising BibTeX/BibLaTeX reference list formatter.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blackref-0.2.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file blackref-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: blackref-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for blackref-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e9fd05ed1647204b9400297707d1539838b18ebb995c2ad551d20489a7035d9
MD5 e61e664e3be9a770f6c7d758b3332dbb
BLAKE2b-256 0cc441d1f8a6557f37473d653395b56486f0a979c6227a1b26254d159d4fa2c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page