scripture-guide 1.0.93 → 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 +27 -6
- package/dist/scriptures.mjs +27 -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;
|
|
@@ -32581,6 +32581,23 @@ var loadMaxVerse = function(book, chapter, config) {
|
|
|
32581
32581
|
if (!bookExists(book, config)) return 0;
|
|
32582
32582
|
return config.raw_index[book][parseInt(chapter) - 1];
|
|
32583
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
|
+
};
|
|
32584
32601
|
var detectReferences = (content, callBack, options = null) => {
|
|
32585
32602
|
if (typeof options === "string" || options === null) {
|
|
32586
32603
|
const language = options;
|
|
@@ -32592,7 +32609,8 @@ var detectReferences = (content, callBack, options = null) => {
|
|
|
32592
32609
|
contextScope: "sentence",
|
|
32593
32610
|
maxContextDistance: 500,
|
|
32594
32611
|
enableImpliedBooks: true,
|
|
32595
|
-
enableVerseAbbrev: true
|
|
32612
|
+
enableVerseAbbrev: true,
|
|
32613
|
+
chainAcrossMarkers: true
|
|
32596
32614
|
};
|
|
32597
32615
|
const finalOptions = { ...defaultOptions, ...options };
|
|
32598
32616
|
callBack = callBack ? callBack : (i) => {
|
|
@@ -32603,10 +32621,11 @@ var detectReferences = (content, callBack, options = null) => {
|
|
|
32603
32621
|
const src = config.raw_regex.books.map((i) => i[0]);
|
|
32604
32622
|
const dst = [...new Set(config.raw_regex.books.map((i) => i[1]))];
|
|
32605
32623
|
const books = [...dst, ...src];
|
|
32624
|
+
const langExtra = finalOptions.chainAcrossMarkers === false ? restrictJoinersToStructural(config.lang_extra) : config.lang_extra;
|
|
32606
32625
|
if (finalOptions.contextAware) {
|
|
32607
|
-
return detectReferencesWithContext(content, books,
|
|
32626
|
+
return detectReferencesWithContext(content, books, langExtra, (query) => lookupReference(query, effectiveLanguage), callBack, finalOptions, generateReference);
|
|
32608
32627
|
}
|
|
32609
|
-
return processReferenceDetection(content, books,
|
|
32628
|
+
return processReferenceDetection(content, books, langExtra, (query) => lookupReference(query, effectiveLanguage), callBack);
|
|
32610
32629
|
};
|
|
32611
32630
|
var findReferences = (content, options = null) => {
|
|
32612
32631
|
if (typeof options === "string" || options === null) {
|
|
@@ -32620,7 +32639,8 @@ var findReferences = (content, options = null) => {
|
|
|
32620
32639
|
enableImpliedBooks: true,
|
|
32621
32640
|
enableVerseAbbrev: true,
|
|
32622
32641
|
abbreviations: true,
|
|
32623
|
-
chapterOnly: true
|
|
32642
|
+
chapterOnly: true,
|
|
32643
|
+
chainAcrossMarkers: true
|
|
32624
32644
|
};
|
|
32625
32645
|
const finalOptions = { ...defaultOptions, ...options };
|
|
32626
32646
|
const effectiveLanguage = getEffectiveLanguage(finalOptions.language);
|
|
@@ -32629,7 +32649,8 @@ var findReferences = (content, options = null) => {
|
|
|
32629
32649
|
const dst = [...new Set(config.raw_regex.books.map((i) => i[1]))];
|
|
32630
32650
|
const books = [...dst, ...src];
|
|
32631
32651
|
const lookup = (query) => lookupReference(query, effectiveLanguage);
|
|
32632
|
-
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);
|
|
32633
32654
|
let records = found.filter((m) => m.verse_ids.length > 0).map(({ start, end, text, verse_ids }) => ({
|
|
32634
32655
|
start,
|
|
32635
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 = {
|
|
@@ -32532,6 +32532,23 @@ var loadMaxVerse = function(book, chapter, config) {
|
|
|
32532
32532
|
if (!bookExists(book, config)) return 0;
|
|
32533
32533
|
return config.raw_index[book][parseInt(chapter) - 1];
|
|
32534
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
|
+
};
|
|
32535
32552
|
var detectReferences = (content, callBack, options = null) => {
|
|
32536
32553
|
if (typeof options === "string" || options === null) {
|
|
32537
32554
|
const language = options;
|
|
@@ -32543,7 +32560,8 @@ var detectReferences = (content, callBack, options = null) => {
|
|
|
32543
32560
|
contextScope: "sentence",
|
|
32544
32561
|
maxContextDistance: 500,
|
|
32545
32562
|
enableImpliedBooks: true,
|
|
32546
|
-
enableVerseAbbrev: true
|
|
32563
|
+
enableVerseAbbrev: true,
|
|
32564
|
+
chainAcrossMarkers: true
|
|
32547
32565
|
};
|
|
32548
32566
|
const finalOptions = { ...defaultOptions, ...options };
|
|
32549
32567
|
callBack = callBack ? callBack : (i) => {
|
|
@@ -32554,10 +32572,11 @@ var detectReferences = (content, callBack, options = null) => {
|
|
|
32554
32572
|
const src = config.raw_regex.books.map((i) => i[0]);
|
|
32555
32573
|
const dst = [...new Set(config.raw_regex.books.map((i) => i[1]))];
|
|
32556
32574
|
const books = [...dst, ...src];
|
|
32575
|
+
const langExtra = finalOptions.chainAcrossMarkers === false ? restrictJoinersToStructural(config.lang_extra) : config.lang_extra;
|
|
32557
32576
|
if (finalOptions.contextAware) {
|
|
32558
|
-
return detectReferencesWithContext(content, books,
|
|
32577
|
+
return detectReferencesWithContext(content, books, langExtra, (query) => lookupReference(query, effectiveLanguage), callBack, finalOptions, generateReference);
|
|
32559
32578
|
}
|
|
32560
|
-
return processReferenceDetection(content, books,
|
|
32579
|
+
return processReferenceDetection(content, books, langExtra, (query) => lookupReference(query, effectiveLanguage), callBack);
|
|
32561
32580
|
};
|
|
32562
32581
|
var findReferences = (content, options = null) => {
|
|
32563
32582
|
if (typeof options === "string" || options === null) {
|
|
@@ -32571,7 +32590,8 @@ var findReferences = (content, options = null) => {
|
|
|
32571
32590
|
enableImpliedBooks: true,
|
|
32572
32591
|
enableVerseAbbrev: true,
|
|
32573
32592
|
abbreviations: true,
|
|
32574
|
-
chapterOnly: true
|
|
32593
|
+
chapterOnly: true,
|
|
32594
|
+
chainAcrossMarkers: true
|
|
32575
32595
|
};
|
|
32576
32596
|
const finalOptions = { ...defaultOptions, ...options };
|
|
32577
32597
|
const effectiveLanguage = getEffectiveLanguage(finalOptions.language);
|
|
@@ -32580,7 +32600,8 @@ var findReferences = (content, options = null) => {
|
|
|
32580
32600
|
const dst = [...new Set(config.raw_regex.books.map((i) => i[1]))];
|
|
32581
32601
|
const books = [...dst, ...src];
|
|
32582
32602
|
const lookup = (query) => lookupReference(query, effectiveLanguage);
|
|
32583
|
-
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);
|
|
32584
32605
|
let records = found.filter((m) => m.verse_ids.length > 0).map(({ start, end, text, verse_ids }) => ({
|
|
32585
32606
|
start,
|
|
32586
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",
|