An open API service indexing awesome lists of open source software.

https://github.com/joelmon/estienne

Estienne is a simple and easy-to-use library for parsing Biblical verses.
https://github.com/joelmon/estienne

bible markdown-parser notes nwt scriptures study

Last synced: 11 days ago
JSON representation

Estienne is a simple and easy-to-use library for parsing Biblical verses.

Awesome Lists containing this project

README

          

# Estienne

A digital image generated by an AI of a bearded man reading from a large book in the style of medieval painting.

[![Rust](https://github.com/JoelMon/Estienne/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/JoelMon/Estienne/actions/workflows/rust.yml)
[![Crates.io](https://img.shields.io/crates/v/estienne.svg)](https://crates.io/crates/estienne)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Project Status: WIP](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)

Estienne is a Rust library that scans plain text for Bible scriptures and helps you format or link them to online Bibles. It targets apps that work with notes, articles, and transcripts where scripture mentions appear in normal prose. No special markup is required for detecting and manipulating scriptures in text.

Estienne is early-stage software and the API can change. It already ships tested functions for formatting and linking verses and can be used.

## What Estienne Does

- Detect Bible references in a string using a locale-aware parser.
- Wrap references with custom prefix and postfix text for styling.
- Turn references into markdown links that point to a specific online Bible (currently JW.org).
- Return the raw references or their index positions for custom processing.

## The Name
The library is named after Robert Estienne, a French theologian of the early Christian era.
He is best remembered for being the first to print the New Testament divided with numbered verses. [Read More](https://www.jw.org/finder?wtlocale=E&docid=2016167&srctype=wol&srcid=share&par=14)

## API at a glance
- `surround(text, prefix, postfix) -> Result`: wraps each detected reference.
- `url(&Site, text) -> Result`: inserts markdown links to the given site.
- `get_scriptures(text) -> Result, BibleError>`: returns validated references.
- `get_locations(text) -> Locations`: returns reference start and end indexes plus the original string.

## Status and roadmap
- Current focus: stability, better locale coverage, and richer parsing of ranged references.
- Short term: expand supported locales and improve error messages.
- Expect breaking changes until a stable release is tagged.

## Installation

```shell
cargo add estienne
```

## Examples

### Highlight references inline

```rust
let text = "A popular scripture is John 3:16, it's quoted often.";
let highlighted = est::surround(text, "", "").unwrap();
assert_eq!(
highlighted,
"A popular scripture is John 3:16, it's quoted often."
);
```

### Create markdown links to JW.org

```rust
use est::locales::nwt_en::Site::JwOrg;

let text = "Read Revelation 21:3-4 for comfort.";
let linked = est::url(&JwOrg, text).unwrap();
assert_eq!(linked, vec!["Read [Revelation 21:3-4](https://www.jw.org/en/library/bible/study-bible/books/revelation/21/#v66021003-v66021004) for comfort."]);
```

### Extract scriptures as plain strings

```rust
let text = "Cross reference Psalm 83:18 with Matthew 24:14.";
let refs = est::get_scriptures(text).unwrap();
assert_eq!(refs, vec!["Psalm 83:18", "Matthew 24:14"]);
```

### Get the locations of each scripture found in a string

```rust
use est::{get_locations, Locations};

let text = "John 3:16 pairs well with 1 John 4:8.";
let locations: Locations = get_locations(text);
assert_eq!(locations.slices, vec![(0, 9), (24, 35)]);
assert_eq!(locations.string, text);
```

## Contributing
Contributions are welcomed, but please be aware that the project is still in a very early phase and large portions of code might change at any moment. Feel free to open an issue if you have any questions, suggestions, or bug reports.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE.txt) file for details.