scripture-guide 1.0.13 → 1.0.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripture-guide",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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": {
@@ -485,6 +485,7 @@ var loadMaxVerse = function loadMaxVerse(book, chapter) {
485
485
  return raw_index[book][parseInt(chapter) - 1];
486
486
  };
487
487
  var detectReferences = function detectReferences(content, callBack) {
488
+ var _content$match;
488
489
  callBack = callBack ? callBack : function (i) {
489
490
  return "[".concat(i, "]");
490
491
  };
@@ -499,16 +500,19 @@ var detectReferences = function detectReferences(content, callBack) {
499
500
  });
500
501
  var pattern = preparePattern(bookMatchList, wordBreak = "", lang_extra);
501
502
  var blacklist_pattern = prepareBlacklist();
502
- var matches = content.match(pattern).filter(function (i) {
503
+ var matches = ((_content$match = content.match(pattern)) === null || _content$match === void 0 ? void 0 : _content$match.filter(function (i) {
503
504
  return !blacklist_pattern.test(i);
505
+ })) || [];
506
+ matches = matches.map(function (i) {
507
+ return i.replace(/[,;!?.]$/, "").trim();
504
508
  });
505
509
 
506
510
  //split by matches
507
- var pieces = content.split(new RegExp("(".concat(matches.join("|"), ")"), "ig"));
511
+ var pieces = matches.length ? content.split(new RegExp("(".concat(matches.join("|"), ")"), "ig")) : [content];
508
512
  content = pieces.map(function (i, j) {
509
513
  if (j % 2 == 0) return i;
510
514
  return callBack(i);
511
- }).join(" ").replace(/\s+/g, " ").trim();
515
+ }).join("").replace(/\s+/g, " ").trim();
512
516
  return content;
513
517
  };
514
518
  module.exports = {
package/scriptures.js CHANGED
@@ -486,15 +486,17 @@ const detectReferences = (content,callBack) => {
486
486
  const bookMatchList = [...dst, ...src].map(i => [i]);
487
487
  const pattern = preparePattern(bookMatchList,wordBreak="",lang_extra);
488
488
  const blacklist_pattern = prepareBlacklist();
489
- var matches = content.match(pattern).filter(i=>!blacklist_pattern.test(i));
489
+ var matches = content.match(pattern)?.filter(i=>!blacklist_pattern.test(i)) || [];
490
+
491
+ matches = matches.map(i=>i.replace(/[,;!?.]$/,"").trim());
490
492
 
491
493
  //split by matches
492
- const pieces = content.split(new RegExp(`(${matches.join("|")})`, "ig"));
494
+ const pieces = matches.length? content.split(new RegExp(`(${matches.join("|")})`, "ig")) : [content];
493
495
 
494
496
  content = pieces.map((i,j)=>{
495
497
  if(j%2==0) return i;
496
498
  return callBack(i);
497
- }).join(" ").replace(/\s+/g," ").trim();
499
+ }).join("").replace(/\s+/g," ").trim();
498
500
 
499
501
  return content;
500
502
  }
package/test-detect.js CHANGED
@@ -22,7 +22,9 @@ const ko_lines = [
22
22
  "이제 제4니파이서 1장 4~5절 참조하십시오.",
23
23
  "이제 제4니파이서 1.4~5절 참조하십시오.",
24
24
  "이제 제4니파이서 4~5절 참조하십시오.",
25
- "이제 모세서 3장 참조하십시오."
25
+ "이제 모세서 3장 참조하십시오.",
26
+ "이제 참조하십시오.",
27
+ "test this please"
26
28
  ]
27
29
  ko_lines.forEach(l=>{
28
30
  let callback = (string)=>{