scripture-guide 1.0.14 → 1.0.16
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 +5 -2
- package/scriptures.js +3 -2
- package/test-detect.js +6 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scripture-guide",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
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
|
@@ -503,13 +503,16 @@ var detectReferences = function detectReferences(content, callBack) {
|
|
|
503
503
|
var matches = ((_content$match = content.match(pattern)) === null || _content$match === void 0 ? void 0 : _content$match.filter(function (i) {
|
|
504
504
|
return !blacklist_pattern.test(i);
|
|
505
505
|
})) || [];
|
|
506
|
+
matches = matches.map(function (i) {
|
|
507
|
+
return i.trim().replace(/[,;!?.]+/ig, "").trim();
|
|
508
|
+
});
|
|
506
509
|
|
|
507
510
|
//split by matches
|
|
508
|
-
var pieces = content.split(new RegExp("(".concat(matches.join("|"), ")"), "ig"))
|
|
511
|
+
var pieces = matches.length ? content.split(new RegExp("(".concat(matches.join("|"), ")"), "ig")) : [content];
|
|
509
512
|
content = pieces.map(function (i, j) {
|
|
510
513
|
if (j % 2 == 0) return i;
|
|
511
514
|
return callBack(i);
|
|
512
|
-
}).join("
|
|
515
|
+
}).join("").replace(/\s+/g, " ").trim();
|
|
513
516
|
return content;
|
|
514
517
|
};
|
|
515
518
|
module.exports = {
|
package/scriptures.js
CHANGED
|
@@ -487,14 +487,15 @@ const detectReferences = (content,callBack) => {
|
|
|
487
487
|
const pattern = preparePattern(bookMatchList,wordBreak="",lang_extra);
|
|
488
488
|
const blacklist_pattern = prepareBlacklist();
|
|
489
489
|
var matches = content.match(pattern)?.filter(i=>!blacklist_pattern.test(i)) || [];
|
|
490
|
+
matches = matches.map(i => i.trim().replace(/[,;!?.]+/ig, "").trim());
|
|
490
491
|
|
|
491
492
|
//split by matches
|
|
492
|
-
const pieces = content.split(new RegExp(`(${matches.join("|")})`, "ig"))
|
|
493
|
+
const pieces = matches.length? content.split(new RegExp(`(${matches.join("|")})`, "ig")) : [content];
|
|
493
494
|
|
|
494
495
|
content = pieces.map((i,j)=>{
|
|
495
496
|
if(j%2==0) return i;
|
|
496
497
|
return callBack(i);
|
|
497
|
-
}).join("
|
|
498
|
+
}).join("").replace(/\s+/g," ").trim();
|
|
498
499
|
|
|
499
500
|
return content;
|
|
500
501
|
}
|
package/test-detect.js
CHANGED
|
@@ -4,7 +4,8 @@ const {lookup, generateReference, setLanguage, detectReferences}= require("./scr
|
|
|
4
4
|
|
|
5
5
|
const lines = [
|
|
6
6
|
"Please refer to Genesis 20 in the bible",
|
|
7
|
-
"Please refer to 3 Nephi 5:1-3 in the Book of Mormon"
|
|
7
|
+
"Please refer to 3 Nephi 5:1-3 in the Book of Mormon",
|
|
8
|
+
"For example, in Matthew 27:51, the earth quakes and ro"
|
|
8
9
|
]
|
|
9
10
|
|
|
10
11
|
lines.forEach(l=>{
|
|
@@ -12,6 +13,8 @@ lines.forEach(l=>{
|
|
|
12
13
|
console.log({result});
|
|
13
14
|
});
|
|
14
15
|
|
|
16
|
+
process.exit(0);
|
|
17
|
+
|
|
15
18
|
setLanguage("ko");
|
|
16
19
|
|
|
17
20
|
const ko_lines = [
|
|
@@ -22,7 +25,8 @@ const ko_lines = [
|
|
|
22
25
|
"이제 제4니파이서 1장 4~5절 참조하십시오.",
|
|
23
26
|
"이제 제4니파이서 1.4~5절 참조하십시오.",
|
|
24
27
|
"이제 제4니파이서 4~5절 참조하십시오.",
|
|
25
|
-
"이제 모세서 3장 참조하십시오."
|
|
28
|
+
"이제 모세서 3장 참조하십시오.",
|
|
29
|
+
"이제 참조하십시오.",
|
|
26
30
|
]
|
|
27
31
|
ko_lines.forEach(l=>{
|
|
28
32
|
let callback = (string)=>{
|