scripture-guide 1.0.26 → 1.0.28

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.
@@ -12,6 +12,7 @@ const prepareBlacklist = (lang_extras) => {
12
12
  blacklist.push("\\b(AC3|PS2|PS3|PS4)\\b"); //Common file extentions
13
13
  blacklist.push("\\b(ps|PS)[1-9]\\b"); //Common file extentions'
14
14
 
15
+
15
16
  var blacklist_pattern = new RegExp("(" + blacklist.join("|") + ")", 'g');
16
17
 
17
18
  return blacklist_pattern;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripture-guide",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
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": {
@@ -522,6 +522,9 @@ var detectReferences = function detectReferences(content, callBack) {
522
522
  callBack = callBack ? callBack : function (i) {
523
523
  return "[".concat(i, "]");
524
524
  };
525
+ var trimExternalMatchStrings = function trimExternalMatchStrings(i) {
526
+ return i.trim().replace(/^[^0-9]*\(/g, '').replace(/\)[^0-9]*$/g, '').replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim();
527
+ };
525
528
  var hasNoAlpha = !/[A-Za-z]/.test(content);
526
529
  if (hasNoAlpha && wordBreak) wordBreak = "";
527
530
  var src = raw_regex.books.map(function (i) {
@@ -538,11 +541,9 @@ var detectReferences = function detectReferences(content, callBack) {
538
541
  var matches = ((_content$match = content.match(pattern)) === null || _content$match === void 0 ? void 0 : _content$match.filter(function (i) {
539
542
  return !blacklist_pattern.test(i);
540
543
  })) || [];
541
- matches = matches.map(function (i) {
542
- return i.trim().replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim();
543
- });
544
+ matches = matches.map(trimExternalMatchStrings);
544
545
  matches = matches.filter(function (i) {
545
- return i.length <= 100;
546
+ return i.length <= 1000;
546
547
  });
547
548
 
548
549
  // split by matches
@@ -550,7 +551,11 @@ var detectReferences = function detectReferences(content, callBack) {
550
551
  try {
551
552
  pieces = matches.length ? content.split(new RegExp("(".concat(matches.join("|"), ")"), "ig")) : [content];
552
553
  } catch (error) {
553
- console.log('Invalid regular expression:', error);
554
+ console.error(error);
555
+ console.log({
556
+ matches: matches,
557
+ pattern: pattern
558
+ });
554
559
  return content;
555
560
  }
556
561
  content = pieces.map(function (i, j) {
package/scriptures.js CHANGED
@@ -506,6 +506,13 @@ const detectReferences = (content,callBack,wordBreak="\\b") => {
506
506
 
507
507
  callBack = callBack ? callBack : (i)=>{return `[${i}]`};
508
508
 
509
+ const trimExternalMatchStrings = (i) => i.trim().
510
+ replace(/^[^0-9]*\(/g, '').
511
+ replace(/\)[^0-9]*$/g, '').
512
+ replace(/[,;!?.()]+$/ig, "").
513
+ replace(/^[,;!?.()]+/ig, " ").
514
+ trim();
515
+
509
516
  const hasNoAlpha = !/[A-Za-z]/.test(content);
510
517
  if(hasNoAlpha && wordBreak) wordBreak = "";
511
518
 
@@ -515,15 +522,16 @@ const detectReferences = (content,callBack,wordBreak="\\b") => {
515
522
  const pattern = preparePattern(bookMatchList,wordBreak,lang_extra);
516
523
  const blacklist_pattern = prepareBlacklist();
517
524
  var matches = content.match(pattern)?.filter(i => !blacklist_pattern.test(i)) || [];
518
- matches = matches.map(i => i.trim().replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim())
519
- matches = matches.filter(i => i.length <= 100);
525
+ matches = matches.map(trimExternalMatchStrings)
526
+ matches = matches.filter(i => i.length <= 1000);
520
527
 
521
528
  // split by matches
522
529
  let pieces;
523
530
  try {
524
531
  pieces = matches.length ? content.split(new RegExp(`(${matches.join("|")})`, "ig")) : [content];
525
532
  } catch (error) {
526
- console.log('Invalid regular expression:', error);
533
+ console.error(error);
534
+ console.log({matches,pattern});
527
535
  return content;
528
536
  }
529
537
 
package/test-detect.js CHANGED
@@ -6,7 +6,7 @@ const lines = [
6
6
  "Please refer to Genesis 20 in the bible",
7
7
  "Please refer to 3 Nephi 5:1-3 in the Book of Mormon",
8
8
  "For example, in Matthew 27:51, the earth quakes and ro",
9
- "(Here is a compound referece) at (the end of a sentence. (Alma 5:1-3; 6:7-9; Genesis 1:1-2)",
9
+ "It aligns with other scriptures (3 Nephi 12:2, Mosiah 18:13, Moses 6:52).",
10
10
  ]
11
11
 
12
12
  lines.forEach(l=>{