scripture-guide 1.0.50 → 1.0.51
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/package.json +1 -1
- package/scriptures-compiled.js +8 -5
- package/scriptures.js +8 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scripture-guide",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.51",
|
|
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
|
@@ -252,13 +252,16 @@ var handleSingleChapterBookRefs = function handleSingleChapterBookRefs(ref) {
|
|
|
252
252
|
};
|
|
253
253
|
var splitReferences = function splitReferences(compoundReference) {
|
|
254
254
|
var refs = compoundReference.split(/\s*;\s*/);
|
|
255
|
-
var runningBook =
|
|
255
|
+
var runningBook = "";
|
|
256
256
|
var completeRefs = [];
|
|
257
257
|
for (var i in refs) {
|
|
258
|
-
var
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
var ref = refs[i];
|
|
259
|
+
var pieces = ref.split(/([0-9:,-]+)$/);
|
|
260
|
+
var firstPiece = pieces[0].trim();
|
|
261
|
+
runningBook = bookExists(firstPiece) ? firstPiece : runningBook;
|
|
262
|
+
var needsPreBook = !bookExists(firstPiece);
|
|
263
|
+
var preBook = needsPreBook && runningBook ? runningBook : "";
|
|
264
|
+
completeRefs.push((preBook + " " + ref).trim());
|
|
262
265
|
}
|
|
263
266
|
return completeRefs;
|
|
264
267
|
};
|
package/scriptures.js
CHANGED
|
@@ -91,7 +91,6 @@ const lookupReference = function(query) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
const lookupSingleRef = function(ref) {
|
|
94
|
-
|
|
95
94
|
const booksWithDashRegex = /^(joseph|조셉)/i; // TODO: get from lang config
|
|
96
95
|
//todo: better handling of multi-book ranges for unicode
|
|
97
96
|
if (!booksWithDashRegex.test(ref) && ref.match(/[—-](\d\s)*[\D]/ig)) return lookupMultiBookRange(ref);
|
|
@@ -232,7 +231,6 @@ const cleanReference = function(messyReference) {
|
|
|
232
231
|
|
|
233
232
|
cleanReference = handleSingleChapterBookRefs(cleanReference);
|
|
234
233
|
if (!cleanReference.match(/:/)) cleanReference = cleanReference.replace(/,/, "; ");
|
|
235
|
-
|
|
236
234
|
return cleanReference;
|
|
237
235
|
}
|
|
238
236
|
|
|
@@ -247,13 +245,16 @@ const handleSingleChapterBookRefs = function(ref) {
|
|
|
247
245
|
|
|
248
246
|
const splitReferences = function(compoundReference) {
|
|
249
247
|
let refs = compoundReference.split(/\s*;\s*/);
|
|
250
|
-
let runningBook =
|
|
248
|
+
let runningBook = "";
|
|
251
249
|
let completeRefs = [];
|
|
252
250
|
for (let i in refs) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
251
|
+
const ref = refs[i];
|
|
252
|
+
let pieces = ref.split(/([0-9:,-]+)$/);
|
|
253
|
+
const firstPiece = pieces[0].trim();
|
|
254
|
+
runningBook = bookExists(firstPiece) ? firstPiece : runningBook;
|
|
255
|
+
const needsPreBook = !bookExists(firstPiece);
|
|
256
|
+
const preBook = needsPreBook && runningBook ? runningBook : "";
|
|
257
|
+
completeRefs.push((preBook + " " + ref).trim());
|
|
257
258
|
}
|
|
258
259
|
return completeRefs;
|
|
259
260
|
}
|