scripture-guide 1.0.14 → 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.14",
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": {
@@ -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.replace(/[,;!?.]$/, "").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(" ").replace(/\s+/g, " ").trim();
515
+ }).join("").replace(/\s+/g, " ").trim();
513
516
  return content;
514
517
  };
515
518
  module.exports = {
package/scriptures.js CHANGED
@@ -488,13 +488,15 @@ const detectReferences = (content,callBack) => {
488
488
  const blacklist_pattern = prepareBlacklist();
489
489
  var matches = content.match(pattern)?.filter(i=>!blacklist_pattern.test(i)) || [];
490
490
 
491
+ matches = matches.map(i=>i.replace(/[,;!?.]$/,"").trim());
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)=>{