Skip to main content

elm-bible-rs

Parse, validate, format and encode English Bible references, in Rust, with Python bindings.

>>> import elm_bible_rs
>>> ref = elm_bible_rs.parse("1 cor 13:4-7")
>>> str(ref)
'1 Corinthians 13:4-7'
>>> ref.encode()
(46013004, 46013007)
>>> elm_bible_rs.format(19023001, 19023006)
'Psalm 23:1-6'
>>> elm_bible_rs.parse("Gen 51")
Traceback (most recent call last):
  ...
elm_bible_rs.InvalidReference: Genesis only has 50 chapters

elm-bible-rs is a port of the Elm package monty5811/elm-bible. It gives the same answer, and the same error message, as the Elm code for every input, so a server in Python and a frontend in Elm can share one idea of what a reference is. COMPAT.md covers what that includes.

Installing

pip install elm-bible-rs

The wheels are abi3, for CPython 3.11 and later, on Linux (x86_64, aarch64) and macOS. Elsewhere pip builds the sdist, which needs a Rust toolchain.

The crate isn't on crates.io. To use it from Rust, depend on the git repository:

elm-bible-rs = { git = "https://github.com/monty5811/elm-bible", tag = "rs-2.1.0" }

Versions

elm-bible-rs X.Y.Z matches elm-bible X.Y.Z: same parsing, formatting, validation, book table and error messages. A Python project that also has an Elm frontend should pin both to the same version and bump them together.

The Rust and Python package is released from rs-X.Y.Z tags, separate from the Elm package's bare X.Y.Z tags. If elm-bible-rs needs a fix that doesn't change behaviour (packaging, say) without a new Elm release, it gets a post-release on PyPI (X.Y.Z.post1, tag rs-X.Y.Z.post1), so the version still names the Elm release it matches.

What it accepts

  • Genesis
  • Genesis 1
  • Genesis 1:1
  • Genesis 1:1-20
  • Genesis 1:20-2:24
  • Genesis 1-5
  • Genesis 1 - Exodus 5
  • Genesis 1:1 - Exodus 5
  • Genesis 1 - Exodus 5:20
  • Genesis 1:1 - Exodus 5:20
  • Genesis - Exodus 5
  • Genesis - Revelation

Books can be abbreviated, with or without a trailing dot: Gen, 1 Sam, I Sam, 1st Sam, First Samuel, Ps., Psalms, Jhn and others (Book.aliases). Case and whitespace don't matter, and text after the reference is ignored (John 3:16 (ESV)). Hyphens, en dashes and em dashes all work as the dash. Chapter and verse numbers start at 1, and John 3.16 is an error rather than John 3. In a single-chapter book (Obadiah, Philemon, 2 John, 3 John, Jude), the number is a verse: Jude 3-5.

Only English names and the 66-book Protestant canon are supported.

Encoding

Each verse encodes as book * 1_000_000 + chapter * 1_000 + verse, so Genesis 1:1 is 1001001. A reference is a (start, end) pair, which you can store as two integer columns. Plain integer comparisons then give sorting, "which passages touch Romans 8", and so on.

Python API

elm_bible_rs.parse(text: str) -> Reference              # raises InvalidReference
elm_bible_rs.decode(start: int, end: int) -> Reference  # raises InvalidReference
elm_bible_rs.format(start: int, end: int) -> str        # decode(...).format()

Reference.start, .end, .encode()
Reference.start_book, .start_chapter, .start_verse  # Book, int, int
Reference.end_book, .end_chapter, .end_verse
Reference.format(), str(ref)                        # "Genesis 1:1-5"
                                                    # (immutable, hashable, ==)

Book.Genesis ... Book.Revelation                    # ordered, hashable, int(book)
Book.all(), elm_bible_rs.BOOKS                          # all 66, in order
Book.from_number(19)                                # Book.Psalms
book.number, .name ("Psalm"), .title ("Psalms"), .chapters,
book.verse_counts, .verses(chapter), .testament ("OT" | "NT"), .aliases

InvalidReference(ValueError)                        # str(e): the message,
                                                    # e.code: "chapter_out_of_range", ...

The package ships type stubs (py.typed).

Rust API

let r: elm_bible_rs::Reference = "Gen 1:1-5".parse()?;
assert_eq!(r.to_string(), "Genesis 1:1-5");
let r = elm_bible_rs::Reference::decode(1_001_001, 1_001_005)?;
let text = elm_bible_rs::format(1_001_001, 1_001_005)?;

The Python bindings are behind the python feature, so the crate has no dependencies without it.

Developing

elm-bible-rs lives in rust/ of the elm-bible repo, next to the Elm package it ports (../src). A change to src/ must keep rust/ passing, in the same PR. CI enforces it. COMPAT.md has the steps.

From the repo root:

yarn install                                        # elm and node tools, for compat/
cargo test --manifest-path rust/Cargo.toml          # unit and property (proptest) tests
uv venv && uv pip install ./rust --group rust/pyproject.toml:test  # build the extension into a venv
.venv/bin/pytest rust/tests                         # the Python bindings, including hypothesis properties
python3 rust/scripts/gen_tables.py --check          # tables match ../src
.venv/bin/python rust/compat/corpus.py diff --quick # Elm vs elm-bible-rs on the ~4k curated cases
.venv/bin/python rust/compat/corpus.py diff         # Elm vs elm-bible-rs on the full ~510k generated cases
python3 rust/compat/corpus.py changes --from monty5811/elm-bible@2.1.0  # what src/ changes since a release

.github/workflows/ci.yml runs all of these.

Metadata

Release files for elm-bible-rs 2.1.0

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

Source distribution (sdist)

Source distribution for elm-bible-rs 2.1.0
File Size Uploaded Provenance Actions
elm_bible_rs-2.1.0.tar.gz 33.3 kB With provenance Details for elm_bible_rs-2.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for elm-bible-rs 2.1.0
File Actions
elm_bible_rs-2.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for elm_bible_rs-2.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
elm_bible_rs-2.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for elm_bible_rs-2.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
elm_bible_rs-2.1.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for elm_bible_rs-2.1.0-cp311-abi3-macosx_11_0_arm64.whl
elm_bible_rs-2.1.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for elm_bible_rs-2.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 1.1 MB

Release files / elm_bible_rs-2.1.0.tar.gz

Download URL elm_bible_rs-2.1.0.tar.gz
Size 33.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b65472e1f38d8d58565b408af152d074239f1bcff74b029b24fb39f0d9f0ccdc
BLAKE2b-256 checksum
How to use checksums
2e8ba90e69a3cd49b66168b71e8a4a8dff0d52c6ddf81b668c50a1f6d9ceed71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / elm_bible_rs-2.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL elm_bible_rs-2.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 268.2 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
5a0f75e74780847f078d15f3dbb92410557faa5cb103b3c9a0a6d1147dab2818
BLAKE2b-256 checksum
How to use checksums
e57e06d2f9886bb931473a0fa296e23ecc1b56c68cf6db321d00ce8732ad3f41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / elm_bible_rs-2.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL elm_bible_rs-2.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 271.1 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
5dc7f2269e738606231f015548f7fa9b760cebf3fc16c514195a77cd75f25124
BLAKE2b-256 checksum
How to use checksums
62146e1f9e891f2035d622d38d9b00ab9512c655282552e1dc00c0282db5adb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / elm_bible_rs-2.1.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL elm_bible_rs-2.1.0-cp311-abi3-macosx_11_0_arm64.whl
Size 246.7 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6f8711559038613f8764a7bdbf046ff4411b88da389a5689cc8b3e774f2969c7
BLAKE2b-256 checksum
How to use checksums
4e09fd22b4a87b0efc9fb5104229a98d709ff52655cdf20ff3be31f70b6ad6c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / elm_bible_rs-2.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL elm_bible_rs-2.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 250.7 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
da7ddc5785c949b44270497aeb924f91aed09c6be361de4fd6ed282772c0f4f2
BLAKE2b-256 checksum
How to use checksums
307e2bfb38b0fe582453b3768b0e6950617ec1e513f2991d95dba2454a6aa779
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for elm-bible-rs 2.1.0

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for elm_bible_rs-2.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

2.1.0 This release

5 release files Full provenance

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