1.0.55 • Published 2 days ago

scripture-guide v1.0.55

Weekly downloads
-
License
ISC
Repository
github
Last release
2 days ago

Scripture Reference Parser

This universal scripture reference parser is designed to lookup any reference to a scriptural text and return the corresponding verse ids. These verse ids can then be used to query a database using a verse id index, such as those found on https://scriptures.nephi.org/

Scripture Reference Conventions

Scripture references generally follow standard conventions for citing the Bible. Various style guides have different conventions for citing the bible, but they are all generally recgoniziable by the elements of Book, Chapter, and Verse. Multiple reference types exist for citing various combinations of book, verse, or chapter ranges, discreet passages, and non-sequential verses within a single chapter or book, or across multiple chapters and/or books.

Prerequisites

  • This scripture reference parser executes in a JavaScript envrionment. (Both NodeJS and major browsers supported)

Installing

Install the package:

npm i scripture-guide

Import and use the package:

import {lookupReference,generateReference} from 'scripture-guide';

const verses = lookupReference('Jn 3:16');
console.log(verses);
// { query: 'Jn 3:16', ref: 'John 3:16', verse_ids: [ 26137 ] }
//  John 3:16 is the 26137th verse in the Bible

const ref = generateReference([ 26137, 26138, 26139 ]);
console.log(ref);
// John 3:16-18

INPUT—Supported Reference Types

Reference TypeExample
Simple referenceExodus 1:1
Simple chapterGenesis 2
Split chaptersGenesis 1,3
Chapter rangeExodus 3-5
Chapter range and splitExodus 3-5,8
Verse rangeExodus 20:1-10
Verse range and splitExodus 20:1-5,10
Verse SplitExodus 20:5,10
Verse range spanning multiple chaptersExodus 1:5-4:3
Chapter range ending in partial chapterExodus 3-4:10
Chapter range spanning multiple booksGenesis 30—Exodus 2
Chapter range spanning multiple books, ending in partial chapterGenesis 30—Exodus 2:5
Chapter range spanning multiple books, starting in partial chapterGenesis 30:10—Exodus 2
Chapter range spanning multiple books, starting and ending with partial chaptersGenesis 30:10 - Exodus 2:5
Compound reference in same bookExodus 5:1;6:2;8:5
Compound reference in different booksExodus 5:1; Leviticus 6:2; Numbers 8:5
Compound reference ranges in different booksExodus 5:1-3; Leviticus 6:2-5; Numbers 8:5-6
Entire Book RangeGenesis - Numbers
Abbreviation detectionMt 2.5; Mk 3; Lk 4; Jn 5.2-6; 1 Jn1.5,7-8; 3 Jn1.1

Example

A scripture reference string is passed into the scripture object’s lookupReference() function like this:

let results = scripture.lookupReference('Ex 20.5,10');

OUTPUT—Verse IDs

The function will return a json object containing the following:

  • query: the user-provided input string (what was said)
  • ref: the parsed, interpreted reference string (what was meant)
  • verse_ids: the resuluting array containing the verse ID integers corresponding to the input query
{
    "query": "Ex 20.5,10",
    "ref": "Exodus 20:5, 10",
    "verse_ids": [ 2057, 2062 ]
}

Using Verse IDs

  • Verse IDs are intended to be used to query a scripture database. (Database not included).
  • Verse IDs are calculated as a function of number of verses away from Genesis 1:1, inclusive, using the conventionally standard sequence of books, chapters, and verses.

Example Verse IDs:

VerseVerse ID
Genesis 1:11
Genesis 1:22
Genesis 1:1010
Genesis 1:3131
Genesis 2:132
Genesis 50:261533
Exodus 1:11534
Exodus 1:21535
Malachi 4:623145

See also: Master Verse ID list

Example Database Usage:

Assuming a verse_id–index database table named scripture_verses exists

SELECT * FROM `scripture_verses` WHERE verse_id IN (2057, 2062);

This query will enable the retrieval of the text associated with the input reference, mediated by verse IDs.

Customizing Verse IDs

  • The data/scriptdata.json file contains the sequential index from which verse_ids are calculated.
  • If needed, this file may be edited to correspond to a difference database index
  • The data structure is:
{
    "Book 1 Name": 
        [
            "verse count (int) of chapter 1",
            "verse count (int) of chapter 2",
            "verse count (int) of chapter 3",
            "verse count (int) of chapter 4"
        ],
    "Book 2 Name": 
        [
            "verse count (int) of chapter 1",
            "verse count (int) of chapter 2",
            "verse count (int) of chapter 3"
        ],
}

Following this structure, the verse_ids corresponding to each book, chapter and verse may be modified according to the desired sequenital index.

Authors

  • KC Kern - Initial work - kckern

npm run build && node test.js

1.0.55

2 days ago

1.0.54

2 days ago

1.0.53

2 days ago

1.0.52

2 months ago

1.0.51

2 months ago

1.0.50

2 months ago

1.0.49

2 months ago

1.0.48

2 months ago

1.0.47

2 months ago

1.0.46

2 months ago

1.0.45

2 months ago

1.0.40

3 months ago

1.0.44

3 months ago

1.0.43

3 months ago

1.0.42

3 months ago

1.0.41

3 months ago

1.0.39

3 months ago

1.0.38

3 months ago

1.0.33

3 months ago

1.0.37

3 months ago

1.0.36

3 months ago

1.0.35

3 months ago

1.0.34

3 months ago

1.0.19

6 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.16

6 months ago

1.0.9

6 months ago

1.0.22

6 months ago

1.0.21

6 months ago

1.0.20

6 months ago

1.0.26

6 months ago

1.0.25

6 months ago

1.0.24

6 months ago

1.0.23

6 months ago

1.0.29

6 months ago

1.0.28

6 months ago

1.0.27

6 months ago

1.0.11

6 months ago

1.0.32

5 months ago

1.0.10

6 months ago

1.0.31

5 months ago

1.0.30

6 months ago

1.0.15

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

6 months ago

1.0.8

8 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago