A library for working with Bible references.
Get a formatted String from a Reference.
Some example outputs:
It may be useful to have a unique, compact representation of a reference for storage, searching, sorting, etc.
An easy way to achieve this is to convert the start and end of the reference to an Int.
These integers can then be stored in a database, sorted, checked for intersections to do searches, etc.
The encoding process is as follows:
(1000000 * Book.toInt book) + (1000 * chapter) + verseThis results in an Int with the following structure
16001001
--===___
| | |
| | |
| | |--- Zero padded verse number
| |------ Zero padded chapter number
|-------- Book numberConvert a reference to an encoded representation.
(fromString "Gen 1:1 - Rev 5") |> Result.map encode)
== Ok {start = 1001001, end = 66005014}Attempt to convert an encoded value to a reference.
Fails if either value is outside Genesis 1:1 to Revelation 22:21, or the reference isn't valid.
These functions may be useful if you want to build your own formatter, or something else.
Bible.Book has the names, numbers and sizes of the books.
Get the book the reference starts with.
Get the name of the book the reference starts with.
Get the name of the book the reference ends with.
Get the chapter the reference starts with.
Get the chapter the reference ends with.
Get the verse the reference starts with.
Get the verse the reference ends with.
An opaque type to represent a Bible reference.
Attempt to convert a
Stringinto aReference.The following formats should work:
Book names can be written in full or abbreviated, in any case, with or without a trailing dot:
Psalm 23,Psalms 23,Ps. 23,1 Cor 13,I Cor 13,First Corinthians 13,Jhn 3:16. Any whitespace works between the parts, and-,–and—all work as dashes.Text after the reference is ignored, so
John 3:16 (ESV)is John 3:16.