scripture-guide 1.0.91 → 1.0.93
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/dist/scriptures.cjs +80 -4
- package/dist/scriptures.mjs +80 -4
- package/package.json +1 -1
package/dist/scriptures.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* scripture-guide v1.0.
|
|
1
|
+
/* scripture-guide v1.0.93 */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -3270,6 +3270,14 @@ var en_default3 = {
|
|
|
3270
3270
|
"\\bcanticle of canticles\\b",
|
|
3271
3271
|
"Solomon's Song"
|
|
3272
3272
|
],
|
|
3273
|
+
[
|
|
3274
|
+
"\\bjs[\\s\u2013\u2014-]+h(?:ist(?:ory)?)?\\b",
|
|
3275
|
+
"jsh"
|
|
3276
|
+
],
|
|
3277
|
+
[
|
|
3278
|
+
"\\bjs[\\s\u2013\u2014-]+m(?:att(?:hew)?)?\\b",
|
|
3279
|
+
"jsm"
|
|
3280
|
+
],
|
|
3273
3281
|
[
|
|
3274
3282
|
"\\bIV\\s+(?=[A-Za-z])",
|
|
3275
3283
|
"4 "
|
|
@@ -31610,7 +31618,9 @@ var findMatches = (content, books, lang_extra) => {
|
|
|
31610
31618
|
const tail = lang_extra.tail ? new RegExp(lang_extra.tail, "ig") : /[^0-9]+$/;
|
|
31611
31619
|
const preBookMatch = lang_extra.book || `(First|I|1|1st|Second|II|2|2nd|Third|III|3|3rd|Fourth|IV|4|4th)*\\s*(books* of)*\\s*`;
|
|
31612
31620
|
const matchingBooks = findMatchingBooks(normalizedContent, books);
|
|
31613
|
-
const
|
|
31621
|
+
const gap = "[ \\t]*(?:\\n(?![ \\t]*\\n)[ \\t]*)?(?:,[ \\t]*sec(?:tion)?\\.?[ \\t]*)?\\(?[ \\t]*(?=[0-9])";
|
|
31622
|
+
const core = "(?:[0-9:.;,~\u2014\u2013-]|[ \\t]|\\n(?![ \\t]*\\n)|and\\b|cf\\b|\\()*[0-9]";
|
|
31623
|
+
const postBookMatch = lang_extra.chapter || gap + core;
|
|
31614
31624
|
const fullBookMatches = matchingBooks.map((bookMatch) => {
|
|
31615
31625
|
const patternString = preBookMatch + bookMatch;
|
|
31616
31626
|
const pattern = new RegExp(patternString, "ig");
|
|
@@ -31668,7 +31678,7 @@ var findMatches = (content, books, lang_extra) => {
|
|
|
31668
31678
|
return newString.replace(tail, "").trim();
|
|
31669
31679
|
}).filter((i) => !!i);
|
|
31670
31680
|
const matches = matchesWithReferences.map((string) => {
|
|
31671
|
-
const pattern = new RegExp(string, "ig");
|
|
31681
|
+
const pattern = new RegExp(string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "ig");
|
|
31672
31682
|
const matches2 = normalizedContent.match(pattern)?.map((i) => i.trim().replace(tail, ""));
|
|
31673
31683
|
return matches2;
|
|
31674
31684
|
}).flat().reduce((prev, current) => {
|
|
@@ -32244,6 +32254,9 @@ var strToHash = function(str) {
|
|
|
32244
32254
|
};
|
|
32245
32255
|
var cleanReference = function(messyReference, config) {
|
|
32246
32256
|
let ref = messyReference.replace(/[\s]+/g, " ").trim();
|
|
32257
|
+
ref = ref.replace(/(\d)\s+and\s+(\d)/g, "$1,$2");
|
|
32258
|
+
ref = ref.replace(/[()]/g, " ");
|
|
32259
|
+
ref = ref.replace(/\bsec(?:tion)?\b\.?/ig, " ");
|
|
32247
32260
|
let regex = config.raw_regex.pre_rules;
|
|
32248
32261
|
for (let i in regex) {
|
|
32249
32262
|
var re = new RegExp(regex[i].pattern ?? regex[i][0], "ig");
|
|
@@ -32617,15 +32630,78 @@ var findReferences = (content, options = null) => {
|
|
|
32617
32630
|
const books = [...dst, ...src];
|
|
32618
32631
|
const lookup = (query) => lookupReference(query, effectiveLanguage);
|
|
32619
32632
|
const found = finalOptions.contextAware ? collectReferencesWithContext(content, books, config.lang_extra, lookup, finalOptions) : collectReferences(content, books, config.lang_extra, lookup);
|
|
32620
|
-
|
|
32633
|
+
let records = found.filter((m) => m.verse_ids.length > 0).map(({ start, end, text, verse_ids }) => ({
|
|
32621
32634
|
start,
|
|
32622
32635
|
end,
|
|
32623
32636
|
text,
|
|
32624
32637
|
verse_ids,
|
|
32625
32638
|
ref: generateReference(verse_ids, effectiveLanguage)
|
|
32626
32639
|
}));
|
|
32640
|
+
const spelled = collectSpelledOut(content, lookup, effectiveLanguage).filter((sp) => !records.some((r) => sp.start < r.end && r.start < sp.end));
|
|
32641
|
+
if (spelled.length) {
|
|
32642
|
+
records = [...records, ...spelled].sort((a, b) => a.start - b.start);
|
|
32643
|
+
}
|
|
32627
32644
|
return applyDetectionFlags(records, finalOptions);
|
|
32628
32645
|
};
|
|
32646
|
+
var ORDINAL_ONES = ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth"];
|
|
32647
|
+
var ORDINAL_TEENS = { tenth: 10, eleventh: 11, twelfth: 12, thirteenth: 13, fourteenth: 14, fifteenth: 15, sixteenth: 16, seventeenth: 17, eighteenth: 18, nineteenth: 19 };
|
|
32648
|
+
var ORDINAL_TENS = { twentieth: 20, thirtieth: 30 };
|
|
32649
|
+
var CARDINAL_TENS = { twenty: 20, thirty: 30 };
|
|
32650
|
+
var ORDINAL_WORD_RE = "(?:twenty-(?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth)|thirty-(?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth)|" + Object.keys(ORDINAL_TENS).join("|") + "|" + Object.keys(ORDINAL_TEENS).join("|") + "|" + ORDINAL_ONES.slice(1).join("|") + ")";
|
|
32651
|
+
var ordinalToNumber = (word) => {
|
|
32652
|
+
const digit = word.match(/^(\d+)(?:st|nd|rd|th)?$/i);
|
|
32653
|
+
if (digit) return parseInt(digit[1], 10);
|
|
32654
|
+
const w = word.toLowerCase();
|
|
32655
|
+
if (ORDINAL_TEENS[w] != null) return ORDINAL_TEENS[w];
|
|
32656
|
+
if (ORDINAL_TENS[w] != null) return ORDINAL_TENS[w];
|
|
32657
|
+
const dash = w.split("-");
|
|
32658
|
+
if (dash.length === 2 && CARDINAL_TENS[dash[0]] != null) {
|
|
32659
|
+
const one2 = ORDINAL_ONES.indexOf(dash[1]);
|
|
32660
|
+
if (one2 > 0) return CARDINAL_TENS[dash[0]] + one2;
|
|
32661
|
+
}
|
|
32662
|
+
const one = ORDINAL_ONES.indexOf(w);
|
|
32663
|
+
return one > 0 ? one : null;
|
|
32664
|
+
};
|
|
32665
|
+
var ANY_ORDINAL = "(\\d+(?:st|nd|rd|th)|" + ORDINAL_WORD_RE + ")";
|
|
32666
|
+
var BOOK_TAIL = "(?:the\\s+)?(?:book\\s+of\\s+)?((?:(?:First|Second|Third|Fourth|1st|2nd|3rd|4th|I{1,3}|IV)\\s+)?[A-Z][a-zA-Z]+)";
|
|
32667
|
+
var isCapitalized = (s) => /^[A-Z]/.test(s);
|
|
32668
|
+
var followsAsName = (content, end) => /^(?:['’]s\b|\s+[A-Z][a-z])/.test(content.slice(end));
|
|
32669
|
+
var collectSpelledOut = (content, lookup, effectiveLanguage) => {
|
|
32670
|
+
const out = [];
|
|
32671
|
+
const push = (start, end, query) => {
|
|
32672
|
+
const result = lookup(query);
|
|
32673
|
+
if (!result.verse_ids || !result.verse_ids.length) return;
|
|
32674
|
+
out.push({
|
|
32675
|
+
start,
|
|
32676
|
+
end,
|
|
32677
|
+
text: content.substring(start, end),
|
|
32678
|
+
verse_ids: result.verse_ids,
|
|
32679
|
+
ref: generateReference(result.verse_ids, effectiveLanguage)
|
|
32680
|
+
});
|
|
32681
|
+
};
|
|
32682
|
+
const verseRe = new RegExp("\\b(?:the\\s+)?" + ANY_ORDINAL + "\\s+verse\\s+of\\s+the\\s+" + ANY_ORDINAL + "\\s+chapter\\s+of\\s+" + BOOK_TAIL, "ig");
|
|
32683
|
+
const claimed = [];
|
|
32684
|
+
let m;
|
|
32685
|
+
while ((m = verseRe.exec(content)) !== null) {
|
|
32686
|
+
const verse = ordinalToNumber(m[1]);
|
|
32687
|
+
const chapter = ordinalToNumber(m[2]);
|
|
32688
|
+
const e0 = m.index + m[0].length;
|
|
32689
|
+
if (verse == null || chapter == null || !isCapitalized(m[3]) || followsAsName(content, e0)) continue;
|
|
32690
|
+
const s = m.index + m[0].indexOf(m[1]);
|
|
32691
|
+
claimed.push([s, e0]);
|
|
32692
|
+
push(s, e0, `${m[3]} ${chapter}:${verse}`);
|
|
32693
|
+
}
|
|
32694
|
+
const chapRe = new RegExp("\\b(?:the\\s+)?" + ANY_ORDINAL + "\\s+chapter\\s+of\\s+" + BOOK_TAIL, "ig");
|
|
32695
|
+
while ((m = chapRe.exec(content)) !== null) {
|
|
32696
|
+
const chapter = ordinalToNumber(m[1]);
|
|
32697
|
+
const e = m.index + m[0].length;
|
|
32698
|
+
if (chapter == null || !isCapitalized(m[2]) || followsAsName(content, e)) continue;
|
|
32699
|
+
const s = m.index + m[0].indexOf(m[1]);
|
|
32700
|
+
if (claimed.some(([cs, ce]) => s < ce && cs < e)) continue;
|
|
32701
|
+
push(s, e, `${m[2]} ${chapter}`);
|
|
32702
|
+
}
|
|
32703
|
+
return out.sort((a, b) => a.start - b.start);
|
|
32704
|
+
};
|
|
32629
32705
|
var bookPortion = (s) => {
|
|
32630
32706
|
const m = s.match(/^\s*(.*?)\s+\d/);
|
|
32631
32707
|
return (m ? m[1] : s).trim().toLowerCase();
|
package/dist/scriptures.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* scripture-guide v1.0.
|
|
1
|
+
/* scripture-guide v1.0.93 */
|
|
2
2
|
|
|
3
3
|
// src/data/canons/bible/structure.mjs
|
|
4
4
|
var structure_default = {
|
|
@@ -3221,6 +3221,14 @@ var en_default3 = {
|
|
|
3221
3221
|
"\\bcanticle of canticles\\b",
|
|
3222
3222
|
"Solomon's Song"
|
|
3223
3223
|
],
|
|
3224
|
+
[
|
|
3225
|
+
"\\bjs[\\s\u2013\u2014-]+h(?:ist(?:ory)?)?\\b",
|
|
3226
|
+
"jsh"
|
|
3227
|
+
],
|
|
3228
|
+
[
|
|
3229
|
+
"\\bjs[\\s\u2013\u2014-]+m(?:att(?:hew)?)?\\b",
|
|
3230
|
+
"jsm"
|
|
3231
|
+
],
|
|
3224
3232
|
[
|
|
3225
3233
|
"\\bIV\\s+(?=[A-Za-z])",
|
|
3226
3234
|
"4 "
|
|
@@ -31561,7 +31569,9 @@ var findMatches = (content, books, lang_extra) => {
|
|
|
31561
31569
|
const tail = lang_extra.tail ? new RegExp(lang_extra.tail, "ig") : /[^0-9]+$/;
|
|
31562
31570
|
const preBookMatch = lang_extra.book || `(First|I|1|1st|Second|II|2|2nd|Third|III|3|3rd|Fourth|IV|4|4th)*\\s*(books* of)*\\s*`;
|
|
31563
31571
|
const matchingBooks = findMatchingBooks(normalizedContent, books);
|
|
31564
|
-
const
|
|
31572
|
+
const gap = "[ \\t]*(?:\\n(?![ \\t]*\\n)[ \\t]*)?(?:,[ \\t]*sec(?:tion)?\\.?[ \\t]*)?\\(?[ \\t]*(?=[0-9])";
|
|
31573
|
+
const core = "(?:[0-9:.;,~\u2014\u2013-]|[ \\t]|\\n(?![ \\t]*\\n)|and\\b|cf\\b|\\()*[0-9]";
|
|
31574
|
+
const postBookMatch = lang_extra.chapter || gap + core;
|
|
31565
31575
|
const fullBookMatches = matchingBooks.map((bookMatch) => {
|
|
31566
31576
|
const patternString = preBookMatch + bookMatch;
|
|
31567
31577
|
const pattern = new RegExp(patternString, "ig");
|
|
@@ -31619,7 +31629,7 @@ var findMatches = (content, books, lang_extra) => {
|
|
|
31619
31629
|
return newString.replace(tail, "").trim();
|
|
31620
31630
|
}).filter((i) => !!i);
|
|
31621
31631
|
const matches = matchesWithReferences.map((string) => {
|
|
31622
|
-
const pattern = new RegExp(string, "ig");
|
|
31632
|
+
const pattern = new RegExp(string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "ig");
|
|
31623
31633
|
const matches2 = normalizedContent.match(pattern)?.map((i) => i.trim().replace(tail, ""));
|
|
31624
31634
|
return matches2;
|
|
31625
31635
|
}).flat().reduce((prev, current) => {
|
|
@@ -32195,6 +32205,9 @@ var strToHash = function(str) {
|
|
|
32195
32205
|
};
|
|
32196
32206
|
var cleanReference = function(messyReference, config) {
|
|
32197
32207
|
let ref = messyReference.replace(/[\s]+/g, " ").trim();
|
|
32208
|
+
ref = ref.replace(/(\d)\s+and\s+(\d)/g, "$1,$2");
|
|
32209
|
+
ref = ref.replace(/[()]/g, " ");
|
|
32210
|
+
ref = ref.replace(/\bsec(?:tion)?\b\.?/ig, " ");
|
|
32198
32211
|
let regex = config.raw_regex.pre_rules;
|
|
32199
32212
|
for (let i in regex) {
|
|
32200
32213
|
var re = new RegExp(regex[i].pattern ?? regex[i][0], "ig");
|
|
@@ -32568,15 +32581,78 @@ var findReferences = (content, options = null) => {
|
|
|
32568
32581
|
const books = [...dst, ...src];
|
|
32569
32582
|
const lookup = (query) => lookupReference(query, effectiveLanguage);
|
|
32570
32583
|
const found = finalOptions.contextAware ? collectReferencesWithContext(content, books, config.lang_extra, lookup, finalOptions) : collectReferences(content, books, config.lang_extra, lookup);
|
|
32571
|
-
|
|
32584
|
+
let records = found.filter((m) => m.verse_ids.length > 0).map(({ start, end, text, verse_ids }) => ({
|
|
32572
32585
|
start,
|
|
32573
32586
|
end,
|
|
32574
32587
|
text,
|
|
32575
32588
|
verse_ids,
|
|
32576
32589
|
ref: generateReference(verse_ids, effectiveLanguage)
|
|
32577
32590
|
}));
|
|
32591
|
+
const spelled = collectSpelledOut(content, lookup, effectiveLanguage).filter((sp) => !records.some((r) => sp.start < r.end && r.start < sp.end));
|
|
32592
|
+
if (spelled.length) {
|
|
32593
|
+
records = [...records, ...spelled].sort((a, b) => a.start - b.start);
|
|
32594
|
+
}
|
|
32578
32595
|
return applyDetectionFlags(records, finalOptions);
|
|
32579
32596
|
};
|
|
32597
|
+
var ORDINAL_ONES = ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth"];
|
|
32598
|
+
var ORDINAL_TEENS = { tenth: 10, eleventh: 11, twelfth: 12, thirteenth: 13, fourteenth: 14, fifteenth: 15, sixteenth: 16, seventeenth: 17, eighteenth: 18, nineteenth: 19 };
|
|
32599
|
+
var ORDINAL_TENS = { twentieth: 20, thirtieth: 30 };
|
|
32600
|
+
var CARDINAL_TENS = { twenty: 20, thirty: 30 };
|
|
32601
|
+
var ORDINAL_WORD_RE = "(?:twenty-(?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth)|thirty-(?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth)|" + Object.keys(ORDINAL_TENS).join("|") + "|" + Object.keys(ORDINAL_TEENS).join("|") + "|" + ORDINAL_ONES.slice(1).join("|") + ")";
|
|
32602
|
+
var ordinalToNumber = (word) => {
|
|
32603
|
+
const digit = word.match(/^(\d+)(?:st|nd|rd|th)?$/i);
|
|
32604
|
+
if (digit) return parseInt(digit[1], 10);
|
|
32605
|
+
const w = word.toLowerCase();
|
|
32606
|
+
if (ORDINAL_TEENS[w] != null) return ORDINAL_TEENS[w];
|
|
32607
|
+
if (ORDINAL_TENS[w] != null) return ORDINAL_TENS[w];
|
|
32608
|
+
const dash = w.split("-");
|
|
32609
|
+
if (dash.length === 2 && CARDINAL_TENS[dash[0]] != null) {
|
|
32610
|
+
const one2 = ORDINAL_ONES.indexOf(dash[1]);
|
|
32611
|
+
if (one2 > 0) return CARDINAL_TENS[dash[0]] + one2;
|
|
32612
|
+
}
|
|
32613
|
+
const one = ORDINAL_ONES.indexOf(w);
|
|
32614
|
+
return one > 0 ? one : null;
|
|
32615
|
+
};
|
|
32616
|
+
var ANY_ORDINAL = "(\\d+(?:st|nd|rd|th)|" + ORDINAL_WORD_RE + ")";
|
|
32617
|
+
var BOOK_TAIL = "(?:the\\s+)?(?:book\\s+of\\s+)?((?:(?:First|Second|Third|Fourth|1st|2nd|3rd|4th|I{1,3}|IV)\\s+)?[A-Z][a-zA-Z]+)";
|
|
32618
|
+
var isCapitalized = (s) => /^[A-Z]/.test(s);
|
|
32619
|
+
var followsAsName = (content, end) => /^(?:['’]s\b|\s+[A-Z][a-z])/.test(content.slice(end));
|
|
32620
|
+
var collectSpelledOut = (content, lookup, effectiveLanguage) => {
|
|
32621
|
+
const out = [];
|
|
32622
|
+
const push = (start, end, query) => {
|
|
32623
|
+
const result = lookup(query);
|
|
32624
|
+
if (!result.verse_ids || !result.verse_ids.length) return;
|
|
32625
|
+
out.push({
|
|
32626
|
+
start,
|
|
32627
|
+
end,
|
|
32628
|
+
text: content.substring(start, end),
|
|
32629
|
+
verse_ids: result.verse_ids,
|
|
32630
|
+
ref: generateReference(result.verse_ids, effectiveLanguage)
|
|
32631
|
+
});
|
|
32632
|
+
};
|
|
32633
|
+
const verseRe = new RegExp("\\b(?:the\\s+)?" + ANY_ORDINAL + "\\s+verse\\s+of\\s+the\\s+" + ANY_ORDINAL + "\\s+chapter\\s+of\\s+" + BOOK_TAIL, "ig");
|
|
32634
|
+
const claimed = [];
|
|
32635
|
+
let m;
|
|
32636
|
+
while ((m = verseRe.exec(content)) !== null) {
|
|
32637
|
+
const verse = ordinalToNumber(m[1]);
|
|
32638
|
+
const chapter = ordinalToNumber(m[2]);
|
|
32639
|
+
const e0 = m.index + m[0].length;
|
|
32640
|
+
if (verse == null || chapter == null || !isCapitalized(m[3]) || followsAsName(content, e0)) continue;
|
|
32641
|
+
const s = m.index + m[0].indexOf(m[1]);
|
|
32642
|
+
claimed.push([s, e0]);
|
|
32643
|
+
push(s, e0, `${m[3]} ${chapter}:${verse}`);
|
|
32644
|
+
}
|
|
32645
|
+
const chapRe = new RegExp("\\b(?:the\\s+)?" + ANY_ORDINAL + "\\s+chapter\\s+of\\s+" + BOOK_TAIL, "ig");
|
|
32646
|
+
while ((m = chapRe.exec(content)) !== null) {
|
|
32647
|
+
const chapter = ordinalToNumber(m[1]);
|
|
32648
|
+
const e = m.index + m[0].length;
|
|
32649
|
+
if (chapter == null || !isCapitalized(m[2]) || followsAsName(content, e)) continue;
|
|
32650
|
+
const s = m.index + m[0].indexOf(m[1]);
|
|
32651
|
+
if (claimed.some(([cs, ce]) => s < ce && cs < e)) continue;
|
|
32652
|
+
push(s, e, `${m[2]} ${chapter}`);
|
|
32653
|
+
}
|
|
32654
|
+
return out.sort((a, b) => a.start - b.start);
|
|
32655
|
+
};
|
|
32580
32656
|
var bookPortion = (s) => {
|
|
32581
32657
|
const m = s.match(/^\s*(.*?)\s+\d/);
|
|
32582
32658
|
return (m ? m[1] : s).trim().toLowerCase();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scripture-guide",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.93",
|
|
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": "dist/scriptures.cjs",
|
|
6
6
|
"module": "dist/scriptures.mjs",
|