scripture-guide 1.0.92 → 1.0.95
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/README.md +1 -0
- package/dist/scriptures.cjs +35 -6
- package/dist/scriptures.mjs +35 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,6 +126,7 @@ detectReferences('In John 3, Jesus explains (v. 16) that God loved the world.');
|
|
|
126
126
|
| `options.language` | string | Language code |
|
|
127
127
|
| `options.contextAware` | boolean | Enable context detection (default: true) |
|
|
128
128
|
| `options.enableImpliedBooks` | boolean | Detect bare verse numbers (default: true) |
|
|
129
|
+
| `options.chainAcrossMarkers` | boolean | Merge references joined by prose markers — `see also`, `cf.`, `compare`, `cited at` — into a single reference (default: true). Set `false` to keep the marker words outside the link: `'A; see also B'` yields two links instead of one. Structural joiners (`;` `,` `&` `and`) still merge either way. |
|
|
129
130
|
|
|
130
131
|
### setLanguage(language)
|
|
131
132
|
|
package/dist/scriptures.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* scripture-guide v1.0.
|
|
1
|
+
/* scripture-guide v1.0.95 */
|
|
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 "
|
|
@@ -32573,6 +32581,23 @@ var loadMaxVerse = function(book, chapter, config) {
|
|
|
32573
32581
|
if (!bookExists(book, config)) return 0;
|
|
32574
32582
|
return config.raw_index[book][parseInt(chapter) - 1];
|
|
32575
32583
|
};
|
|
32584
|
+
var STRUCTURAL_JOINERS = [";", ",", "&", "and"];
|
|
32585
|
+
var isStructuralJoiner = (token) => typeof token === "string" && (!/[a-z]/i.test(token) || token.trim().toLowerCase() === "and");
|
|
32586
|
+
var restrictJoinersToStructural = (lang_extra) => {
|
|
32587
|
+
const src = lang_extra || {};
|
|
32588
|
+
const j = src.joiners;
|
|
32589
|
+
let joiners;
|
|
32590
|
+
if (Array.isArray(j)) {
|
|
32591
|
+
joiners = j.filter(isStructuralJoiner);
|
|
32592
|
+
if (!joiners.length) joiners = [...STRUCTURAL_JOINERS];
|
|
32593
|
+
} else if (j && Array.isArray(j.patterns)) {
|
|
32594
|
+
const patterns = j.patterns.filter(isStructuralJoiner);
|
|
32595
|
+
joiners = patterns.length ? { ...j, patterns } : [...STRUCTURAL_JOINERS];
|
|
32596
|
+
} else {
|
|
32597
|
+
joiners = [...STRUCTURAL_JOINERS];
|
|
32598
|
+
}
|
|
32599
|
+
return { ...src, joiners };
|
|
32600
|
+
};
|
|
32576
32601
|
var detectReferences = (content, callBack, options = null) => {
|
|
32577
32602
|
if (typeof options === "string" || options === null) {
|
|
32578
32603
|
const language = options;
|
|
@@ -32584,7 +32609,8 @@ var detectReferences = (content, callBack, options = null) => {
|
|
|
32584
32609
|
contextScope: "sentence",
|
|
32585
32610
|
maxContextDistance: 500,
|
|
32586
32611
|
enableImpliedBooks: true,
|
|
32587
|
-
enableVerseAbbrev: true
|
|
32612
|
+
enableVerseAbbrev: true,
|
|
32613
|
+
chainAcrossMarkers: true
|
|
32588
32614
|
};
|
|
32589
32615
|
const finalOptions = { ...defaultOptions, ...options };
|
|
32590
32616
|
callBack = callBack ? callBack : (i) => {
|
|
@@ -32595,10 +32621,11 @@ var detectReferences = (content, callBack, options = null) => {
|
|
|
32595
32621
|
const src = config.raw_regex.books.map((i) => i[0]);
|
|
32596
32622
|
const dst = [...new Set(config.raw_regex.books.map((i) => i[1]))];
|
|
32597
32623
|
const books = [...dst, ...src];
|
|
32624
|
+
const langExtra = finalOptions.chainAcrossMarkers === false ? restrictJoinersToStructural(config.lang_extra) : config.lang_extra;
|
|
32598
32625
|
if (finalOptions.contextAware) {
|
|
32599
|
-
return detectReferencesWithContext(content, books,
|
|
32626
|
+
return detectReferencesWithContext(content, books, langExtra, (query) => lookupReference(query, effectiveLanguage), callBack, finalOptions, generateReference);
|
|
32600
32627
|
}
|
|
32601
|
-
return processReferenceDetection(content, books,
|
|
32628
|
+
return processReferenceDetection(content, books, langExtra, (query) => lookupReference(query, effectiveLanguage), callBack);
|
|
32602
32629
|
};
|
|
32603
32630
|
var findReferences = (content, options = null) => {
|
|
32604
32631
|
if (typeof options === "string" || options === null) {
|
|
@@ -32612,7 +32639,8 @@ var findReferences = (content, options = null) => {
|
|
|
32612
32639
|
enableImpliedBooks: true,
|
|
32613
32640
|
enableVerseAbbrev: true,
|
|
32614
32641
|
abbreviations: true,
|
|
32615
|
-
chapterOnly: true
|
|
32642
|
+
chapterOnly: true,
|
|
32643
|
+
chainAcrossMarkers: true
|
|
32616
32644
|
};
|
|
32617
32645
|
const finalOptions = { ...defaultOptions, ...options };
|
|
32618
32646
|
const effectiveLanguage = getEffectiveLanguage(finalOptions.language);
|
|
@@ -32621,7 +32649,8 @@ var findReferences = (content, options = null) => {
|
|
|
32621
32649
|
const dst = [...new Set(config.raw_regex.books.map((i) => i[1]))];
|
|
32622
32650
|
const books = [...dst, ...src];
|
|
32623
32651
|
const lookup = (query) => lookupReference(query, effectiveLanguage);
|
|
32624
|
-
const
|
|
32652
|
+
const langExtra = finalOptions.chainAcrossMarkers === false ? restrictJoinersToStructural(config.lang_extra) : config.lang_extra;
|
|
32653
|
+
const found = finalOptions.contextAware ? collectReferencesWithContext(content, books, langExtra, lookup, finalOptions) : collectReferences(content, books, langExtra, lookup);
|
|
32625
32654
|
let records = found.filter((m) => m.verse_ids.length > 0).map(({ start, end, text, verse_ids }) => ({
|
|
32626
32655
|
start,
|
|
32627
32656
|
end,
|
package/dist/scriptures.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* scripture-guide v1.0.
|
|
1
|
+
/* scripture-guide v1.0.95 */
|
|
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 "
|
|
@@ -32524,6 +32532,23 @@ var loadMaxVerse = function(book, chapter, config) {
|
|
|
32524
32532
|
if (!bookExists(book, config)) return 0;
|
|
32525
32533
|
return config.raw_index[book][parseInt(chapter) - 1];
|
|
32526
32534
|
};
|
|
32535
|
+
var STRUCTURAL_JOINERS = [";", ",", "&", "and"];
|
|
32536
|
+
var isStructuralJoiner = (token) => typeof token === "string" && (!/[a-z]/i.test(token) || token.trim().toLowerCase() === "and");
|
|
32537
|
+
var restrictJoinersToStructural = (lang_extra) => {
|
|
32538
|
+
const src = lang_extra || {};
|
|
32539
|
+
const j = src.joiners;
|
|
32540
|
+
let joiners;
|
|
32541
|
+
if (Array.isArray(j)) {
|
|
32542
|
+
joiners = j.filter(isStructuralJoiner);
|
|
32543
|
+
if (!joiners.length) joiners = [...STRUCTURAL_JOINERS];
|
|
32544
|
+
} else if (j && Array.isArray(j.patterns)) {
|
|
32545
|
+
const patterns = j.patterns.filter(isStructuralJoiner);
|
|
32546
|
+
joiners = patterns.length ? { ...j, patterns } : [...STRUCTURAL_JOINERS];
|
|
32547
|
+
} else {
|
|
32548
|
+
joiners = [...STRUCTURAL_JOINERS];
|
|
32549
|
+
}
|
|
32550
|
+
return { ...src, joiners };
|
|
32551
|
+
};
|
|
32527
32552
|
var detectReferences = (content, callBack, options = null) => {
|
|
32528
32553
|
if (typeof options === "string" || options === null) {
|
|
32529
32554
|
const language = options;
|
|
@@ -32535,7 +32560,8 @@ var detectReferences = (content, callBack, options = null) => {
|
|
|
32535
32560
|
contextScope: "sentence",
|
|
32536
32561
|
maxContextDistance: 500,
|
|
32537
32562
|
enableImpliedBooks: true,
|
|
32538
|
-
enableVerseAbbrev: true
|
|
32563
|
+
enableVerseAbbrev: true,
|
|
32564
|
+
chainAcrossMarkers: true
|
|
32539
32565
|
};
|
|
32540
32566
|
const finalOptions = { ...defaultOptions, ...options };
|
|
32541
32567
|
callBack = callBack ? callBack : (i) => {
|
|
@@ -32546,10 +32572,11 @@ var detectReferences = (content, callBack, options = null) => {
|
|
|
32546
32572
|
const src = config.raw_regex.books.map((i) => i[0]);
|
|
32547
32573
|
const dst = [...new Set(config.raw_regex.books.map((i) => i[1]))];
|
|
32548
32574
|
const books = [...dst, ...src];
|
|
32575
|
+
const langExtra = finalOptions.chainAcrossMarkers === false ? restrictJoinersToStructural(config.lang_extra) : config.lang_extra;
|
|
32549
32576
|
if (finalOptions.contextAware) {
|
|
32550
|
-
return detectReferencesWithContext(content, books,
|
|
32577
|
+
return detectReferencesWithContext(content, books, langExtra, (query) => lookupReference(query, effectiveLanguage), callBack, finalOptions, generateReference);
|
|
32551
32578
|
}
|
|
32552
|
-
return processReferenceDetection(content, books,
|
|
32579
|
+
return processReferenceDetection(content, books, langExtra, (query) => lookupReference(query, effectiveLanguage), callBack);
|
|
32553
32580
|
};
|
|
32554
32581
|
var findReferences = (content, options = null) => {
|
|
32555
32582
|
if (typeof options === "string" || options === null) {
|
|
@@ -32563,7 +32590,8 @@ var findReferences = (content, options = null) => {
|
|
|
32563
32590
|
enableImpliedBooks: true,
|
|
32564
32591
|
enableVerseAbbrev: true,
|
|
32565
32592
|
abbreviations: true,
|
|
32566
|
-
chapterOnly: true
|
|
32593
|
+
chapterOnly: true,
|
|
32594
|
+
chainAcrossMarkers: true
|
|
32567
32595
|
};
|
|
32568
32596
|
const finalOptions = { ...defaultOptions, ...options };
|
|
32569
32597
|
const effectiveLanguage = getEffectiveLanguage(finalOptions.language);
|
|
@@ -32572,7 +32600,8 @@ var findReferences = (content, options = null) => {
|
|
|
32572
32600
|
const dst = [...new Set(config.raw_regex.books.map((i) => i[1]))];
|
|
32573
32601
|
const books = [...dst, ...src];
|
|
32574
32602
|
const lookup = (query) => lookupReference(query, effectiveLanguage);
|
|
32575
|
-
const
|
|
32603
|
+
const langExtra = finalOptions.chainAcrossMarkers === false ? restrictJoinersToStructural(config.lang_extra) : config.lang_extra;
|
|
32604
|
+
const found = finalOptions.contextAware ? collectReferencesWithContext(content, books, langExtra, lookup, finalOptions) : collectReferences(content, books, langExtra, lookup);
|
|
32576
32605
|
let records = found.filter((m) => m.verse_ids.length > 0).map(({ start, end, text, verse_ids }) => ({
|
|
32577
32606
|
start,
|
|
32578
32607
|
end,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scripture-guide",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.95",
|
|
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",
|