Fast Python citation parsing, rendering, and BibTeX editing backed by Rust
Project description
refkit
Refkit parses bibliography files, renders CSL citations, and edits raw BibTeX documents from one Python API.
It supports CPython 3.11 through 3.14. Wheels use the Python 3.11 stable ABI.
import refkit as rk
library = rk.Library.read("refs.bib")
style = rk.Style.load("apa")
doc = rk.Document(library, style, locale="en-US")
first = doc.cite("doe2024")
second = doc.cite([rk.Cite("doe2024", locator="12", label="page"), "roe2022"])
print(first.text)
print(doc.bibliography().html)
Use doc.bibliography(all=True) to render every entry in the library, including entries that were not cited.
One-off calls parse the library, load the style, render, and return a Rendered object.
rk.cite("refs.bib", "doe2024", style="ieee").text
rk.bibliography("refs.bib", style="chicago-author-date").html
Library is the normalized citation database. Use it for rendering, selection, and bulk export.
library = rk.Library.read("refs.yaml")
for entry in library.select("article > periodical[volume]"):
print(entry.key, entry.title, entry.parent.title)
Use Library.parse when the bibliography source is already in memory.
library = rk.Library.parse("@article{doe2024, title={Fast Citations}}")
assert library.get("doe2024").title == "Fast Citations"
BibDocument is the raw .bib document model. Use it when comments, preambles, strings, failed blocks, order, or source spans need to survive an edit.
raw = rk.BibDocument.read("refs.bib")
raw.entries["doe2024"].fields["title"].value = "Corrected title"
raw.write("refs.bib")
Use BibDocument.parse for in-memory repair flows. Call write(path) because parsed documents do not have a source path.
raw = rk.BibDocument.parse("% note\n@article{doe2024, title={Old}}\n")
raw.entries["doe2024"].fields["title"].value = "Corrected title"
raw.write("refs.bib")
Development
uv sync
uv run maturin develop
uv run pytest
Project details
Release history Release notifications | RSS feed
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 refkit-0.0.0.tar.gz.
File metadata
- Download URL: refkit-0.0.0.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
796f859fe97673116472f5f701edd735ba99acd86c325ad34b1cd68a4197c200
|
|
| MD5 |
9e763ee8e6cec48e1fd10458ab439968
|
|
| BLAKE2b-256 |
c92666dd096f3eac7e1f85252975fa00762dd6a277a07495267db0712fb54900
|
File details
Details for the file refkit-0.0.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: refkit-0.0.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2984749176965eb6e1a6a15ffcd94adefdd8c7e63bdfe01132b9e22da5036d2b
|
|
| MD5 |
f64c64efe9b54282303aefe343d86479
|
|
| BLAKE2b-256 |
42d4aa2a82ef8fb00bbefb5adc5158aa1ebdefcb7fe9ff399239c00d20f817cf
|