scripture-guide 1.0.44 → 1.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/scriptdetect.js +10 -5
- package/data/scriptregex.js +1 -1
- package/package.json +1 -1
- package/scriptures-compiled.js +17 -2
- package/scriptures.js +15 -1
- package/test/data/en.txt +3 -1
package/data/scriptdetect.js
CHANGED
|
@@ -20,7 +20,6 @@ const findMatches = (content,books,lang_extra) => {
|
|
|
20
20
|
return stringMatch;
|
|
21
21
|
}).filter(x=>!!x);
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
const bookSubStrings = fullBookMatches.map(bookMatch=>{
|
|
25
24
|
const substrings = content.match(new RegExp(bookMatch,"ig")).flat();
|
|
26
25
|
return substrings;
|
|
@@ -93,8 +92,9 @@ const findMatches = (content,books,lang_extra) => {
|
|
|
93
92
|
|
|
94
93
|
|
|
95
94
|
function findMatchIndexes(content, matches,lookupReference, lang_extra) {
|
|
96
|
-
const tail = lang_extra.tail ? new RegExp(lang_extra.tail,"ig") : /[
|
|
97
|
-
const indexes = matches
|
|
95
|
+
const tail = lang_extra.tail ? new RegExp(lang_extra.tail,"ig") : /[^,; 0-9]+$/;
|
|
96
|
+
const indexes = matches
|
|
97
|
+
.map(i=>{
|
|
98
98
|
const length = i.length;
|
|
99
99
|
let positions = [];
|
|
100
100
|
let strPos = content.indexOf(i);
|
|
@@ -108,8 +108,10 @@ function findMatchIndexes(content, matches,lookupReference, lang_extra) {
|
|
|
108
108
|
.map(a=>{
|
|
109
109
|
|
|
110
110
|
const substring = content.substring(a[0],a[1]).replace(tail,"").trim();
|
|
111
|
+
console.log({a,substring});
|
|
112
|
+
if(!substring) return false;
|
|
111
113
|
const verse_ids = lookupReference(substring).verse_ids;
|
|
112
|
-
|
|
114
|
+
console.log({a,substring,verse_ids});
|
|
113
115
|
if(verse_ids.length > 0) return [a[0],a[0]+substring.length];
|
|
114
116
|
|
|
115
117
|
return false;
|
|
@@ -173,6 +175,7 @@ function findMatchIndexes(content, matches,lookupReference, lang_extra) {
|
|
|
173
175
|
|
|
174
176
|
const processReferenceDetection = (content,books,lang_extra,lookupReference,callback) =>
|
|
175
177
|
{
|
|
178
|
+
try{
|
|
176
179
|
lang_extra = lang_extra || {};
|
|
177
180
|
const matches = findMatches(content,books,lang_extra);
|
|
178
181
|
|
|
@@ -263,7 +266,9 @@ const processReferenceDetection = (content,books,lang_extra,lookupReference,call
|
|
|
263
266
|
|
|
264
267
|
return merged.join("");
|
|
265
268
|
|
|
266
|
-
|
|
269
|
+
}catch(e){
|
|
270
|
+
return content;
|
|
271
|
+
}
|
|
267
272
|
}
|
|
268
273
|
|
|
269
274
|
|
package/data/scriptregex.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scripture-guide",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"description": "A utility for biblical and scripture reference parsing that enables structured queries based on strings of traditional scripture references (e.g. John 3:16). ",
|
|
5
5
|
"main": "scriptures-compiled.js",
|
|
6
6
|
"scripts": {
|
package/scriptures-compiled.js
CHANGED
|
@@ -188,7 +188,6 @@ var cleanReference = function cleanReference(messyReference) {
|
|
|
188
188
|
//Turn dots into colons
|
|
189
189
|
ref = ref.replace(/[.]/g, ":");
|
|
190
190
|
//Treat commas as semicolons in the absence of verses
|
|
191
|
-
if (!ref.match(/:/)) ref = ref.replace(/,/, "; ");
|
|
192
191
|
//add spaces after semicolons
|
|
193
192
|
ref = ref.replace(/;/g, "; ");
|
|
194
193
|
//add space before numbers
|
|
@@ -233,10 +232,26 @@ var cleanReference = function cleanReference(messyReference) {
|
|
|
233
232
|
ref = ref.replace(/\s+/g, " "); //remove double spaces
|
|
234
233
|
ref = ref.replace(/\s*[~–-]\s*/g, "-"); //remove spaces around dashes
|
|
235
234
|
ref = ref.replace(/;(\S+)/g, "; $1"); //add space after semicolons
|
|
236
|
-
|
|
235
|
+
console.log({
|
|
236
|
+
ref: ref
|
|
237
|
+
});
|
|
237
238
|
var cleanReference = ref.trim();
|
|
239
|
+
cleanReference = handleSingleChapterBookRefs(cleanReference);
|
|
240
|
+
if (!cleanReference.match(/:/)) cleanReference = cleanReference.replace(/,/, "; ");
|
|
238
241
|
return cleanReference;
|
|
239
242
|
};
|
|
243
|
+
var handleSingleChapterBookRefs = function handleSingleChapterBookRefs(ref) {
|
|
244
|
+
var singleChapterBooks = Object.keys(raw_index).filter(function (book) {
|
|
245
|
+
return loadMaxChapter(book) == 1;
|
|
246
|
+
});
|
|
247
|
+
var matchingBooks = singleChapterBooks.filter(function (book) {
|
|
248
|
+
return ref.match(new RegExp("^".concat(book, " \\d+")));
|
|
249
|
+
});
|
|
250
|
+
ref = matchingBooks.reduce(function (ref, book) {
|
|
251
|
+
return ref.replace(new RegExp("^".concat(book, " (\\d+)")), "".concat(book, " 1:$1"));
|
|
252
|
+
}, ref);
|
|
253
|
+
return ref;
|
|
254
|
+
};
|
|
240
255
|
var splitReferences = function splitReferences(compoundReference) {
|
|
241
256
|
var refs = compoundReference.split(/\s*;\s*/);
|
|
242
257
|
var runningBook = null;
|
package/scriptures.js
CHANGED
|
@@ -185,7 +185,6 @@ const cleanReference = function(messyReference) {
|
|
|
185
185
|
//Turn dots into colons
|
|
186
186
|
ref = ref.replace(/[.]/g, ":");
|
|
187
187
|
//Treat commas as semicolons in the absence of verses
|
|
188
|
-
if (!ref.match(/:/)) ref = ref.replace(/,/, "; ");
|
|
189
188
|
//add spaces after semicolons
|
|
190
189
|
ref = ref.replace(/;/g, "; ");
|
|
191
190
|
//add space before numbers
|
|
@@ -228,10 +227,25 @@ const cleanReference = function(messyReference) {
|
|
|
228
227
|
ref = ref.replace(/\s+/g, " "); //remove double spaces
|
|
229
228
|
ref = ref.replace(/\s*[~–-]\s*/g, "-"); //remove spaces around dashes
|
|
230
229
|
ref = ref.replace(/;(\S+)/g, "; $1"); //add space after semicolons
|
|
230
|
+
console.log({ref});
|
|
231
231
|
|
|
232
232
|
let cleanReference = ref.trim();
|
|
233
|
+
|
|
234
|
+
cleanReference = handleSingleChapterBookRefs(cleanReference);
|
|
235
|
+
if (!cleanReference.match(/:/)) cleanReference = cleanReference.replace(/,/, "; ");
|
|
236
|
+
|
|
233
237
|
return cleanReference;
|
|
234
238
|
}
|
|
239
|
+
|
|
240
|
+
const handleSingleChapterBookRefs = function(ref) {
|
|
241
|
+
|
|
242
|
+
const singleChapterBooks = Object.keys(raw_index).filter(book => loadMaxChapter(book) == 1);
|
|
243
|
+
const matchingBooks = singleChapterBooks.filter(book => ref.match(new RegExp(`^${book} \\d+`)));
|
|
244
|
+
ref = matchingBooks.reduce((ref,book) => ref.replace(new RegExp(`^${book} (\\d+)`),`${book} 1:$1`),ref);
|
|
245
|
+
|
|
246
|
+
return ref;
|
|
247
|
+
}
|
|
248
|
+
|
|
235
249
|
const splitReferences = function(compoundReference) {
|
|
236
250
|
let refs = compoundReference.split(/\s*;\s*/);
|
|
237
251
|
let runningBook = null;
|
package/test/data/en.txt
CHANGED
|
@@ -25,4 +25,6 @@ Note Source
|
|
|
25
25
|
WB includes “hindrance, opposition,” though both Jacob and Nephi knew of Jesus’s future crucifixion; see 2 Nephi 6.9;1 Ne 11.33;19.10.
|
|
26
26
|
“Everlasting death” • Here and in 2 Nephi 10:23, can be contrasted with the temporary death that everyone will experience and then be rescued from by the Resurrection. Elsewhere the BoM uses the term “second death” to describe the post-resurrection, post-judgment separation from God that will never end (e.g., Alma 12.32: “a second death, which was an everlasting death”).
|
|
27
27
|
The combination of repentance, baptism, faith, and enduring to the end (along with the Holy Ghost) is identified as the doctrine of Christ at 2 Nephi 31.2–21, and the essence of the gospel at 3 Ne 27.13–22. Although Jacob in these two verses, and later Nephi (in ch. 31), speaks in general, abstract terms about baptism, there are no recorded baptisms in the BoM until Alma baptizes at Mos 18, nearly four hundred years later, where the practice appears to be something new.
|
|
28
|
-
|
|
28
|
+
<p>In the Joseph Smith Translation of the Bible, we read that “the Lord hath visited” Joseph, the son of Jacob spoken of in the Old Testament, and that Joseph was given great promises concerning his posterity (JST, Genesis 50:24). As Lehi testified, “Joseph truly saw our day” (2 Nephi 3:5), meaning the day of Lehi and his posterity, and knew that in the future God would raise up “a choice seer” (verse 7), namely the great prophet who was his namesake (see verse 15). Joseph knew also that it would be primarily his descendants whom the Lord would call upon first in these last days to carry the gospel to additional lost members of the house of Israel scattered among the nations of the earth, in compliance with the covenant God made with Abraham (see Bible Dictionary, “Joseph,” 716–17; Guide to the Scriptures, “Joseph, Son of Jacob”). Obviously, since the Lord kept His covenant with Joseph, He will also keep His covenants with us if we are righteous as well.</p><p>Lehi’s teaching is a great example of how Heavenly Father honored the covenant He made with Joseph. We can have the confidence that God will always honor His covenants.</p>
|
|
29
|
+
It is well to remember that the word Nephite apparently had a different meaning near the close of the Book of Mormon than it did before A.D. 231. (See 4 Nephi 20, 36-39.) From approximately 544 B.C. to A.D. 34 (Jacob 1:13-14) the term Nephite referred either to the descendants of Nephi and those who went with him into the wilderness (2 Nephi 5:5-8) or to those who joined with this group. From about A.D. 34 to nearly A.D. 194, there were not “any manner of -ites” among the descendants of Lehi. (4 Nephi 17.) By A.D. 194, however, a group of people revolted from the church and took upon themselves the name of Lamanites (4 Nephi 20), and by A.D. 231 those who had remained true to the church became known as Nephites (4 Nephi 36). For the remainder of the Book of Mormon, the term Nephite apparently refers to the descendants of those who had been faithful in A.D. 231.
|
|
30
|
+
*<p>The Land of Zarahemla represents a central and pivotal region in the historical narrative laid out in the Book of Mormon. Situated in the northern part of the land southward, this area was intersected by the River Sidon (Alma 2:15) and became a melting pot of various peoples, cultures, and political change. Initially founded by the Mulekites, who departed from the Old World and eventually migrated from their landing site in the land to the north, the land of Zarahemla was established in the sixth century B.C. (Omni 1:15, Alma 22:29-31). The city of Zarahemla and its people, led by a man named Zarahemla, were discovered by Mosiah1 and the Nephites around 200 B.C. as they fled the land of Nephi, leading to the unification of the two groups under Mosiah’s kingship (Omni 1:12-19).</p><p>The land and its capital city played host to pivotal historical events including the establishment of churches by Alma1, the commencement of the reign of judges with Alma2 as the first chief judge, and as the stage for military confrontations and the preaching of prophets such as Samuel the Lamanite (Mosiah 25:15-23, Mosiah 29:42, Hel. 13–16). It faced invasions and periods of occupation by the Lamanites interspersed with times of peace and righteous leadership (Alma 61-62:9, Hel. 1:14-33, Hel. 4:1-17).</p><p>The land of Zarahemla was eventually destroyed by fire during the cataclysmic events that accompanied the death of Jesus Christ (3 Ne. 8:8, 24; 9:3). Nonetheless, it was rebuilt and flourished in the first century A.D., only for its population and structures to be overwhelmed once more by conflicts between the Nephites and the Lamanites, leading up to Mormon’s narrative in the fourth century A.D. (4 Ne. 1:8, Morm. 1:6-7, Morm. 1:10). The Land of Zarahemla, as recounted in the Book of Mormon, stands as a witness to cycles of righteousness and wickedness, prosperity and desolation, and functions as a profound symbol within the overarching sacred history depicted in the text.</p>
|