An uncompromising BibTeX/BibLaTeX reference list formatter.
Project description
Blackref: An Uncompromising BibTeX/BibLaTeX Formatter
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
stdinand writes tostdoutby 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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blackref-0.2.1.tar.gz.
File metadata
- Download URL: blackref-0.2.1.tar.gz
- Upload date:
- Size: 34.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3fb3998f3e1e7167018c70ce16caaaa69a0923020e84a254cdf645ceba1fe1b
|
|
| MD5 |
958ce0e0c7109577b6836832c03aa2bc
|
|
| BLAKE2b-256 |
7fcebfa49c9472fad1b1fdf250c87ea2fbd5d7a105c8ee5cb4517465a2c03696
|
File details
Details for the file blackref-0.2.1-py3-none-any.whl.
File metadata
- Download URL: blackref-0.2.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98c6d34745549d05c169f44f0c7b61f0f9f15a015eb8486f54697aa9cef092a8
|
|
| MD5 |
dec37e2f9d02a7916b5f4593ead422c0
|
|
| BLAKE2b-256 |
a826ddb56d5e1b01350413a9eba147a5c3f20cbe55271763913309527a62dfef
|