scripture-guide 1.0.81 → 1.0.82

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.
@@ -289,8 +289,8 @@ const raw_lang = {
289
289
  [";\\s*Giao", "và Giao"],
290
290
  ],
291
291
  books:{
292
- "Sáng Thế": ["STK[yý]", "Sáng Thế Ký","S[áa]ng *Th[ếe] *(K[yý])*"], "Xuất Ê Díp Tô": ["X[ÊE]DT(K[ýy])*","X[úu]at *Ê *D[íi]p *T[ôo] *(K[yý])*","Xu[ấa]t h[àa]nh *(k[yý])*"], "Lê Vi": ["L[êe] *Vi *(K[yý])*","LV(K[ýy])*"], "Dân Số": ["DS(K[yý])*","D[âa]n *S[ốo] *(K[yý])*"], "Phục Truyền Luật Lệ": ["PTLL(K[yý])*","Ph[úu]c *Truy[ềe]n *Lu[ậa]t *L[ệe] *(K[yý])*"], "Giô Suê": ["Gi[ôo] *Su[êe]"], "Các Quan Xét": ["C[áa]c *Quan *X[ée]t","QX[ée]t"], "Ru Tơ": ["Ru *T[ơo]"], "1 Sa Mu Ên": ["1 *Sa *Mu *Ên","1 *SM[EÊ]n"], "2 Sa Mu Ên": ["2 *Sa *Mu *Ên","2 *SM[EÊ]n"], "1 Các Vua": ["1 *C[áa]c *Vua","1 *Vua"], "2 Các Vua": ["2 *C[áa]c *Vua","2 *Vua"], "1 Sử Ký": ["1 *S[ửu] *K[yý]"], "2 Sử Ký": ["2 *S[ửu] *K[yý]"], "E Xơ Ra": ["E *X[ơo] *Ra"], "Nê Hê Mi": ["N[êe] *H[êe] *Mi"], "Ê Xơ Tê": ["Ê *X[ơo] *T[êe]"], "Gióp": ["Gi[óo]p"], "Thi Thiên": ["Th*i* *Thi[êe]n"], "Châm Ngôn": ["Ch[âa]m *Ng[ôo]n","CNg[ôo]n"], "Truyền Đạo": ["T[DĐ][aạ]o","Truy[ềe]n *[ĐD]a[ọo]"], "Nhã Ca": ["Nh[ãa] *Ca"], "Ê Sai": ["[ÊE] *Sai"], "Giê Rê Mi": ["GRMi","Gi[êe] *R[êe] *Mi"], "Ca Thương": ["CTh[uư][oơ]ng","Ca *Th[ưu]ng"], "Ê Xê Chi Ên": ["[EÊ]XC[EÊ]n","Ê *X[êe] *Chi *[ÊE]n"], "Đa Ni Ên": ["[DĐ]N[EÊ]n","[ĐD]a *Ni *[ÊE]n"], "Ô Sê": ["[ÔO] *S[êe]"], "Giô Ên": ["Gi[ôo] *[ÊE]n"], "A Mốt": ["A *M[ốo]t"], "Áp Đia": ["[ÁA]p *Đia"], "Giô Na": ["Gi[ôo] *Na"], "Mi Chê": ["Mi *Ch[êe]"], "Na Hum": ["Na *Hum"], "Ha Ba Cúc": ["HBCuc","Ha *Ba *C[úu]c"], "Sô Phô Ni": ["S[ôo]* *Ph*[ôo]* *Ni"], "A Ghê": ["A *Gh[êe]"], "Xa Cha Ri": ["Xa* *Ch*a* *Ri"], "Ma La Chi": ["Ma* *La* *Chi"],
293
- "Ma Thi Ơ": ["Ma *Thi *[ƠO]","MT[OƠ]"], "Mác": ["M[áa]c"], "Lu Ca": ["Lu *Ca"], "Giăng": ["Gio*[ăa]ng*"], "Công Vụ Các Sứ Đồ": ["C[ôo]ng *Vụ *C[áa]c *Sứ *Đ[ồo]", "CVCS[ĐD]"], "Rô Ma": ["R[ôo] *Ma"], "1 Cô Rinh Tô": ["1 *C[ôo]* *Ri*n*h* *T[ôo]"], "2 Cô Rinh Tô": ["2 *C[ôo]* *Ri*n*h* *T[ôo]"], "Ga La Ti": ["Ga *La *Ti"], "Ê Phê Sô": ["[ÊE] *Ph[êe] *S[ôo]","[ÊE]PS[ÔO]"], "Phi Líp": ["Phi *L[íi]p"], "Cô Lô Se": ["C[ôo] *L[ôo] *Se","CL[ÔO]*Se"], "1 Tê Sa Lô Ni Ca": ["1 *Tê *Sa *L[ôo] *Ni *Ca","1 *TSLN[ÔO]Ca","1 TSLNCa"], "2 Tê Sa Lô Ni Ca": ["2 TSLNCa","2 *Tê *Sa *L[ôo] *Ni *Ca","2 *TSLN[ÔO]Ca"], "1 Ti Mô Thê": ["1 *Ti *Mô *Th[êe]","1 *TMTh[ÊE]"], "2 Ti Mô Thê": ["2 *Ti *Mô *Th[êe]","2 *TMTh[ÊE]"], "Tít": ["T[íi]t"], "Phi Lê Môn": ["Phi *L[êe] *Môn","PL[ÊE]M[ÔO]n","PLM[oô]n"], "Hê Bơ Rơ": ["H[êe] *Bơ *Rơ","HBR[ƠO]"], "Gia Cơ": ["GLTi", "Gia *C[ơo]"], "1 Phi E Rơ": ["1 *Phi *E *R[ơo]","1 *PER[ƠO]"], "2 Phi E Rơ": ["2 *Phi *E *R[ơo]","2 *PER[ƠO]"], "1 Giăng": ["1 *Gio*[ăa]ng*"], "2 Giăng": ["2 *Gio*[ăa]ng*"], "3 Giăng": ["3 *Gio*[ăa]ng*"], "Giu Đe": ["Giu *[ĐD]e"], "Khải Huyền": ["Kh[ảa]i *Huy[ềe]n","KHuy[ềe]n"], "1 Nê Phi": ["1 *N[êe] *Phi"], "2 Nê Phi": ["2 *N[êe] *Phi"], "Gia Cốp": ["Gi*a* *C[ốo]p"], "Ê Nót": ["[ÊE] *N[óo]t"], "Gia Rôm": ["Gi*a* *R[ôo]m"], "Ôm Ni": ["[ÔO]m *Ni"], "Lời Mặc Môn": ["L[ờo]i *M[ặa]c *M[ôo]n","LMM[ÔO]n"], "Mô Si A": ["M[ôo] *Si *A"], "An Ma": ["An *Ma"], "Hê La Man": ["H[êe]* *La* *Man"], "3 Nê Phi": ["3 *N[êe] *Phi"], "4 Nê Phi": ["4 *N[êe] *Phi"], "Mặc Môn": ["M[ậa]c *M[ôo]n", "MM[ÔO]n"], "Ê The": ["[ÊE] *The"], "Mô Rô Ni": ["M[ôo] *R[ôo] *Ni","MRN[ÎI]"], "Giáo Lý và Giao Ước": ["Gi[áa]o *L[ýi] *v[àa] *Giao *[ƯU][ớo]c","GLG[ƯU]"], "Môi Se": ["M[ôo]i *Se"], "Áp Ra Ham": ["[ÁA]p *Ra *Ham","ARH[ÂA]m"], "Joseph Smith—Ma Thi Ơ": ["Joseph *Smith—Ma *Thi *[ƠO]", "JS—MT[ƠO]"], "Joseph Smith—Lịch Sử": ["Joseph *Smith—L[ịi]ch *S[ửu]", "JS—LS"], "Những Tín Điều": ["Nh[ữu]ng *T[íi]n *[ĐD]i[ềe]u", "NT[ĐD]"]
292
+ "Sáng Thế": ["STK[yý]*", "Sáng Thế Ký","S[áa]ng[ -]*Th[ếe][ -]*(K[yý])*"], "Xuất Ê Díp Tô": ["X[ÊE]DT(K[ýy])*","X[úu]at[ -]*Ê[ -]*D[íi]p[ -]*T[ôo][ -]*(K[yý])*","Xu[ấa]t h[àa]nh[ -]*(k[yý])*"], "Lê Vi": ["L[êe][ -]*Vi[ -]*(K[yý])*","LV(K[ýy])*"], "Dân Số": ["DS(K[yý])*","D[âa]n[ -]*S[ốo][ -]*(K[yý])*"], "Phục Truyền Luật Lệ": ["PTLL(K[yý])*","Ph[úu]c[ -]*Truy[ềe]n[ -]*Lu[ậa]t[ -]*L[ệe][ -]*(K[yý])*"], "Giô Suê": ["Gi[ôo][ -]*Su[êe]"], "Các Quan Xét": ["C[áa]c[ -]*Quan[ -]*X[ée]t","QX[ée]t"], "Ru Tơ": ["Ru[ -]*T[ơo]"], "1 Sa Mu Ên": ["1[ -]*Sa[ -]*Mu[ -]*Ên","1[ -]*SM[EÊ]n"], "2 Sa Mu Ên": ["2[ -]*Sa[ -]*Mu[ -]*Ên","2[ -]*SM[EÊ]n"], "1 Các Vua": ["1[ -]*C[áa]c[ -]*Vua","1[ -]*Vua"], "2 Các Vua": ["2[ -]*C[áa]c[ -]*Vua","2[ -]*Vua"], "1 Sử Ký": ["1[ -]*S[ửu][ -]*K[yý]"], "2 Sử Ký": ["2[ -]*S[ửu][ -]*K[yý]"], "E Xơ Ra": ["E[ -]*X[ơo][ -]*Ra"], "Nê Hê Mi": ["N[êe][ -]*H[êe][ -]*Mi"], "Ê Xơ Tê": ["Ê[ -]*X[ơo][ -]*T[êe]"], "Gióp": ["Gi[óo]p"], "Thi Thiên": ["Th*i*[ -]*Thi[êe]n"], "Châm Ngôn": ["Ch[âa]m[ -]*Ng[ôo]n","CNg[ôo]n"], "Truyền Đạo": ["T[DĐ][aạ]o","Truy[ềe]n[ -]*[ĐD]a[ọo]"], "Nhã Ca": ["Nh[ãa][ -]*Ca"], "Ê Sai": ["[ÊE][ -]*Sai"], "Giê Rê Mi": ["GRMi","Gi[êe][ -]*R[êe][ -]*Mi"], "Ca Thương": ["CTh[uư][oơ]ng","Ca[ -]*Th[ưu]ng"], "Ê Xê Chi Ên": ["[EÊ]XC[EÊ]n","Ê[ -]*X[êe][ -]*Chi[ -]*[ÊE]n"], "Đa Ni Ên": ["[DĐ]N[EÊ]n","[ĐD]a[ -]*Ni[ -]*[ÊE]n"], "Ô Sê": ["[ÔO][ -]*S[êe]"], "Giô Ên": ["Gi[ôo][ -]*[ÊE]n"], "A Mốt": ["A[ -]*M[ốo]t"], "Áp Đia": ["[ÁA]p[ -]*Đia"], "Giô Na": ["Gi[ôo][ -]*Na"], "Mi Chê": ["Mi[ -]*Ch[êe]"], "Na Hum": ["Na[ -]*Hum"], "Ha Ba Cúc": ["HBCuc","Ha[ -]*Ba[ -]*C[úu]c"], "Sô Phô Ni": ["S[ôo]*[ -]*Ph*[ôo]*[ -]*Ni"], "A Ghê": ["A[ -]*Gh[êe]"], "Xa Cha Ri": ["Xa*[ -]*Ch*a*[ -]*Ri"], "Ma La Chi": ["Ma*[ -]*La*[ -]*Chi"],
293
+ "Ma Thi Ơ": ["Ma[ -]*Thi[ -]*[ƠO]","MT[OƠ]"], "Mác": ["M[áa]c"], "Lu Ca": ["Lu[ -]*Ca"], "Giăng": ["Gio*[ăa]ng*"], "Công Vụ Các Sứ Đồ": ["C[ôo]ng[ -]*Vụ[ -]*C[áa]c[ -]*Sứ[ -]*Đ[ồo]", "CVCS[ĐD]"], "Rô Ma": ["R[ôo][ -]*Ma"], "1 Cô Rinh Tô": ["1[ -]*C[ôo]*[ -]*Ri*n*h*[ -]*T[ôo]"], "2 Cô Rinh Tô": ["2[ -]*C[ôo]*[ -]*Ri*n*h*[ -]*T[ôo]"], "Ga La Ti": ["Ga[ -]*La[ -]*Ti"], "Ê Phê Sô": ["[ÊE][ -]*Ph[êe][ -]*S[ôo]","[ÊE]PS[ÔO]"], "Phi Líp": ["Phi[ -]*L[íi]p"], "Cô Lô Se": ["C[ôo][ -]*L[ôo][ -]*Se","CL[ÔO]*Se"], "1 Tê Sa Lô Ni Ca": ["1[ -]*Tê[ -]*Sa[ -]*L[ôo][ -]*Ni[ -]*Ca","1[ -]*TSLN[ÔO]Ca","1 TSLNCa"], "2 Tê Sa Lô Ni Ca": ["2 TSLNCa","2[ -]*Tê[ -]*Sa[ -]*L[ôo][ -]*Ni[ -]*Ca","2[ -]*TSLN[ÔO]Ca"], "1 Ti Mô Thê": ["1[ -]*Ti[ -]*Mô[ -]*Th[êe]","1[ -]*TMTh[ÊE]"], "2 Ti Mô Thê": ["2[ -]*Ti[ -]*Mô[ -]*Th[êe]","2[ -]*TMTh[ÊE]"], "Tít": ["T[íi]t"], "Phi Lê Môn": ["Phi[ -]*L[êe][ -]*Môn","PL[ÊE]M[ÔO]n","PLM[oô]n"], "Hê Bơ Rơ": ["H[êe][ -]*Bơ[ -]*Rơ","HBR[ƠO]"], "Gia Cơ": ["GLTi", "Gia[ -]*C[ơo]"], "1 Phi E Rơ": ["1[ -]*Phi[ -]*E[ -]*R[ơo]","1[ -]*PER[ƠO]"], "2 Phi E Rơ": ["2[ -]*Phi[ -]*E[ -]*R[ơo]","2[ -]*PER[ƠO]"], "1 Giăng": ["1[ -]*Gio*[ăa]ng*"], "2 Giăng": ["2[ -]*Gio*[ăa]ng*"], "3 Giăng": ["3[ -]*Gio*[ăa]ng*"], "Giu Đe": ["Giu[ -]*[ĐD]e"], "Khải Huyền": ["Kh[ảa]i[ -]*Huy[ềe]n","KHuy[ềe]n"], "1 Nê Phi": ["1[ -]*N[êe][ -]*Phi"], "2 Nê Phi": ["2[ -]*N[êe][ -]*Phi"], "Gia Cốp": ["Gi*a*[ -]*C[ốo]p"], "Ê Nót": ["[ÊE][ -]*N[óo]t"], "Gia Rôm": ["Gi*a*[ -]*R[ôo]m"], "Ôm Ni": ["[ÔO]m[ -]*Ni"], "Lời Mặc Môn": ["L[ờo]i[ -]*M[ặa]c[ -]*M[ôo]n","LMM[ÔO]n"], "Mô Si A": ["M[ôo][ -]*Si[ -]*A"], "An Ma": ["An[ -]*Ma"], "Hê La Man": ["H[êe]*[ -]*La*[ -]*Man"], "3 Nê Phi": ["3[ -]*N[êe][ -]*Phi"], "4 Nê Phi": ["4[ -]*N[êe][ -]*Phi"], "Mặc Môn": ["M[ậa]c[ -]*M[ôo]n", "MM[ÔO]n"], "Ê The": ["[ÊE][ -]*The"], "Mô Rô Ni": ["M[ôo][ -]*R[ôo][ -]*Ni","MRN[ÎI]"], "Giáo Lý và Giao Ước": ["Gi[áa]o[ -]*L[ýi][ -]*v[àa][ -]*Giao[ -]*[ƯU][ớo]c","GLG[ƯU]"], "Môi Se": ["M[ôo]i[ -]*Se"], "Áp Ra Ham": ["[ÁA]p[ -]*Ra[ -]*Ham","ARH[ÂA]m"], "Joseph Smith—Ma Thi Ơ": ["Joseph[ -]*Smith—Ma[ -]*Thi[ -]*[ƠO]", "JS—MT[ƠO]"], "Joseph Smith—Lịch Sử": ["Joseph[ -]*Smith—L[ịi]ch[ -]*S[ửu]", "JS—LS"], "Những Tín Điều": ["Nh[ữu]ng[ -]*T[íi]n[ -]*[ĐD]i[ềe]u", "NT[ĐD]"]
294
294
  },
295
295
  matchRules:{
296
296
  book: `(Thứ nhất|I|1|Thứ hai|II|2|Thứ ba|III|3|Thứ tư|IV|4)*\\s*(Sách* của)*\\s*`,
@@ -647,26 +647,59 @@ const raw_lang = {
647
647
  }
648
648
  ;
649
649
  const findMatchingBooks = (content,books) => {
650
- const matchingBooks = books.filter(i=>(new RegExp(i,"ig")).test(content));
650
+ const matchingBooks = books.filter(book => {
651
+ try {
652
+ // For Vietnamese and other languages, handle more flexible matching
653
+ let pattern = book;
654
+
655
+ // Replace * with optional space/separator patterns
656
+ pattern = pattern.replace(/\*/g, '');
657
+
658
+ // Make separators very flexible - handle spaces, hyphens, dots, etc.
659
+ pattern = pattern.replace(/[\s\-–—\.]+/g, '[\\s\\-–—\\.]*');
660
+
661
+ const regex = new RegExp(pattern, "ig");
662
+ const result = regex.test(content);
663
+
664
+ return result;
665
+ } catch (e) {
666
+ // Fallback to original logic if regex fails
667
+ return (new RegExp(book,"ig")).test(content);
668
+ }
669
+ });
651
670
  return matchingBooks;
652
671
  }
653
672
 
654
673
  const findMatches = (content,books,lang_extra) => {
674
+ // Pre-process content to normalize HTML entities to Unicode dashes
675
+ const htmlEntityMap = {
676
+ '–': '–',
677
+ '—': '—',
678
+ '−': '–', // Treat minus as en dash for scripture ranges
679
+ '–': '–',
680
+ '—': '—',
681
+ '−': '–' // Treat minus as en dash for scripture ranges
682
+ };
683
+
684
+ let normalizedContent = content;
685
+ Object.entries(htmlEntityMap).forEach(([entity, unicode]) => {
686
+ normalizedContent = normalizedContent.replace(new RegExp(entity, 'g'), unicode);
687
+ });
655
688
 
656
689
  const tail = lang_extra.tail ? new RegExp(lang_extra.tail,"ig") : /[^0-9]+$/;
657
690
  const preBookMatch = lang_extra.book || `(First|I|1|1st|Second|II|2|2nd|Third|III|3|3rd|Fourth|IV|4|4th)*\\s*(books* of)*\\s*`;
658
- const matchingBooks = findMatchingBooks(content,books);
659
- const postBookMatch = lang_extra.chapter || "([0-9:.;,~ —–-]|cf|(?:–))*[0-9]+";
660
- const fullBookMatches = matchingBooks.map(bookMatch=>{
691
+ const matchingBooks = findMatchingBooks(normalizedContent,books);
692
+ const postBookMatch = lang_extra.chapter || "([0-9:.;,~ —–-]|cf)*[0-9]+";
693
+ const fullBookMatches = matchingBooks.map(bookMatch=>{
661
694
  const patternString = preBookMatch + bookMatch ;
662
695
  const pattern = (new RegExp(patternString,"ig"));
663
- const stringMatch = pattern.test(content) ? patternString : null;
696
+ const stringMatch = pattern.test(normalizedContent) ? patternString : null;
664
697
  //console.log({pattern,content,stringMatch});
665
698
  return stringMatch;
666
699
  }).filter(x=>!!x);
667
700
 
668
701
  const bookSubStrings = fullBookMatches.map(bookMatch=>{
669
- const substrings = content.match(new RegExp(bookMatch,"ig")).flat();
702
+ const substrings = normalizedContent.match(new RegExp(bookMatch,"ig")).flat();
670
703
  return substrings;
671
704
  }).flat().reduce((prev,current)=>{
672
705
  if(prev.includes(current)) return prev;
@@ -674,13 +707,13 @@ const fullBookMatches = matchingBooks.map(bookMatch=>{
674
707
  },[]).filter(i=>!!i).map(substring=>{
675
708
  substring = substring.trim();
676
709
  let positions = [];
677
- let index = content.indexOf(substring);
710
+ let index = normalizedContent.indexOf(substring);
678
711
  while (index != -1) {
679
712
  positions.push(index);
680
- index = content.indexOf(substring, index + 1);
713
+ index = normalizedContent.indexOf(substring, index + 1);
681
714
  } return [substring,positions];
682
715
  }).map(([substring,positions])=>{
683
- const preChars = positions.map(i=>content.substring(i-1,i));
716
+ const preChars = positions.map(i=>normalizedContent.substring(i-1,i));
684
717
  positions = positions.filter((i,index)=>{
685
718
  const charRightBeforeMatch = preChars[index];
686
719
  const leadingCharIsInvalid = !/^(\s|\W|)$/.test(charRightBeforeMatch);
@@ -698,7 +731,7 @@ const fullBookMatches = matchingBooks.map(bookMatch=>{
698
731
  }catch(e){
699
732
  return null;
700
733
  }
701
- const match = content.slice(i).match(pattern)?.[0]?.replace(tail,"").trim();
734
+ const match = normalizedContent.slice(i).match(pattern)?.[0]?.replace(tail,"").trim();
702
735
  if(!match) return null;
703
736
  const len = match.length;
704
737
  const pos = i;
@@ -711,12 +744,12 @@ const fullBookMatches = matchingBooks.map(bookMatch=>{
711
744
  const overLappingItems = possiblyOverlappingMatches.filter(([s,s1,e1])=>s!==string && s1<end && e1>end);
712
745
  const hasOverlap = overLappingItems.length > 0;
713
746
  const newEnd = hasOverlap ? Math.min(...overLappingItems.map(([s,s1,e1])=>s1)) : end;
714
- const newString = content.slice(start,newEnd);
747
+ const newString = normalizedContent.slice(start,newEnd);
715
748
  return newString.replace(tail,"").trim();
716
749
  }).filter(i=>!!i);
717
750
  const matches = matchesWithReferences.map(string=>{
718
751
  const pattern = (new RegExp(string,"ig"));
719
- const matches = content.match(pattern)?.map(i=>i.trim().replace(tail,""));
752
+ const matches = normalizedContent.match(pattern)?.map(i=>i.trim().replace(tail,""));
720
753
  //console.log({string,matches,tail});
721
754
  return matches;
722
755
  }).flat()
@@ -724,7 +757,7 @@ const fullBookMatches = matchingBooks.map(bookMatch=>{
724
757
  if(prev.includes(current)) return prev;
725
758
  return [...prev,current]
726
759
  },[]).filter(i=>!!i);
727
- return matches;
760
+ return {matches, normalizedContent};
728
761
  }
729
762
 
730
763
 
@@ -816,8 +849,8 @@ const processReferenceDetection = (content,books,lang_extra,lookupReference,call
816
849
  {
817
850
  try{
818
851
  lang_extra = lang_extra || {};
819
- const matches = findMatches(content,books,lang_extra);
820
- const matchIndeces = findMatchIndexes(content,matches,lookupReference,lang_extra);
852
+ const {matches, normalizedContent} = findMatches(content,books,lang_extra);
853
+ const matchIndeces = findMatchIndexes(normalizedContent,matches,lookupReference,lang_extra);
821
854
  if(!matchIndeces) return content;
822
855
  const gapsBetweenIndeces = matchIndeces.reduce((prev,current,index)=>{
823
856
  if(index === 0) return prev;
@@ -825,7 +858,7 @@ const processReferenceDetection = (content,books,lang_extra,lookupReference,call
825
858
  const gap = [lastPair[1],current[0]];
826
859
  return [...prev,gap];
827
860
  },[]);
828
- const gapStrings = gapsBetweenIndeces.map(([start,end])=>content.substring(start,end).trim());
861
+ const gapStrings = gapsBetweenIndeces.map(([start,end])=>normalizedContent.substring(start,end).trim());
829
862
  //console.log({matches,matchIndeces,gapsBetweenIndeces,gapStrings});
830
863
  const joiners = lang_extra.joiners || ["^[;, ]*(and|c\\.*f\\.*)*$"];
831
864
  const gapThatMayBeMerged = gapsBetweenIndeces.map(([start,end],i)=>{
@@ -874,11 +907,11 @@ const processReferenceDetection = (content,books,lang_extra,lookupReference,call
874
907
 
875
908
  //check content between matches. If puctuation only (or 'and'), then merge
876
909
  const cutItems = mergedIndeces.map(([start,end])=>{
877
- const string = content.substring(start,end);
910
+ const string = normalizedContent.substring(start,end);
878
911
  return lookupReference(string).query
879
912
  }).map(callback);
880
913
 
881
- const negativeItems = negativeSpace.map(([start,end])=>content.substring(start,end));
914
+ const negativeItems = negativeSpace.map(([start,end])=>normalizedContent.substring(start,end));
882
915
  const firstReferenceIsAtStart = mergedIndeces[0][0] === 0;
883
916
  const maxCount = Math.max(cutItems.length,negativeItems.length);
884
917
  //merge by alternating cutItems and negativeItems. run the callback on the cut items
@@ -289,8 +289,8 @@ const raw_lang = {
289
289
  [";\\s*Giao", "và Giao"],
290
290
  ],
291
291
  books:{
292
- "Sáng Thế": ["STK[yý]", "Sáng Thế Ký","S[áa]ng *Th[ếe] *(K[yý])*"], "Xuất Ê Díp Tô": ["X[ÊE]DT(K[ýy])*","X[úu]at *Ê *D[íi]p *T[ôo] *(K[yý])*","Xu[ấa]t h[àa]nh *(k[yý])*"], "Lê Vi": ["L[êe] *Vi *(K[yý])*","LV(K[ýy])*"], "Dân Số": ["DS(K[yý])*","D[âa]n *S[ốo] *(K[yý])*"], "Phục Truyền Luật Lệ": ["PTLL(K[yý])*","Ph[úu]c *Truy[ềe]n *Lu[ậa]t *L[ệe] *(K[yý])*"], "Giô Suê": ["Gi[ôo] *Su[êe]"], "Các Quan Xét": ["C[áa]c *Quan *X[ée]t","QX[ée]t"], "Ru Tơ": ["Ru *T[ơo]"], "1 Sa Mu Ên": ["1 *Sa *Mu *Ên","1 *SM[EÊ]n"], "2 Sa Mu Ên": ["2 *Sa *Mu *Ên","2 *SM[EÊ]n"], "1 Các Vua": ["1 *C[áa]c *Vua","1 *Vua"], "2 Các Vua": ["2 *C[áa]c *Vua","2 *Vua"], "1 Sử Ký": ["1 *S[ửu] *K[yý]"], "2 Sử Ký": ["2 *S[ửu] *K[yý]"], "E Xơ Ra": ["E *X[ơo] *Ra"], "Nê Hê Mi": ["N[êe] *H[êe] *Mi"], "Ê Xơ Tê": ["Ê *X[ơo] *T[êe]"], "Gióp": ["Gi[óo]p"], "Thi Thiên": ["Th*i* *Thi[êe]n"], "Châm Ngôn": ["Ch[âa]m *Ng[ôo]n","CNg[ôo]n"], "Truyền Đạo": ["T[DĐ][aạ]o","Truy[ềe]n *[ĐD]a[ọo]"], "Nhã Ca": ["Nh[ãa] *Ca"], "Ê Sai": ["[ÊE] *Sai"], "Giê Rê Mi": ["GRMi","Gi[êe] *R[êe] *Mi"], "Ca Thương": ["CTh[uư][oơ]ng","Ca *Th[ưu]ng"], "Ê Xê Chi Ên": ["[EÊ]XC[EÊ]n","Ê *X[êe] *Chi *[ÊE]n"], "Đa Ni Ên": ["[DĐ]N[EÊ]n","[ĐD]a *Ni *[ÊE]n"], "Ô Sê": ["[ÔO] *S[êe]"], "Giô Ên": ["Gi[ôo] *[ÊE]n"], "A Mốt": ["A *M[ốo]t"], "Áp Đia": ["[ÁA]p *Đia"], "Giô Na": ["Gi[ôo] *Na"], "Mi Chê": ["Mi *Ch[êe]"], "Na Hum": ["Na *Hum"], "Ha Ba Cúc": ["HBCuc","Ha *Ba *C[úu]c"], "Sô Phô Ni": ["S[ôo]* *Ph*[ôo]* *Ni"], "A Ghê": ["A *Gh[êe]"], "Xa Cha Ri": ["Xa* *Ch*a* *Ri"], "Ma La Chi": ["Ma* *La* *Chi"],
293
- "Ma Thi Ơ": ["Ma *Thi *[ƠO]","MT[OƠ]"], "Mác": ["M[áa]c"], "Lu Ca": ["Lu *Ca"], "Giăng": ["Gio*[ăa]ng*"], "Công Vụ Các Sứ Đồ": ["C[ôo]ng *Vụ *C[áa]c *Sứ *Đ[ồo]", "CVCS[ĐD]"], "Rô Ma": ["R[ôo] *Ma"], "1 Cô Rinh Tô": ["1 *C[ôo]* *Ri*n*h* *T[ôo]"], "2 Cô Rinh Tô": ["2 *C[ôo]* *Ri*n*h* *T[ôo]"], "Ga La Ti": ["Ga *La *Ti"], "Ê Phê Sô": ["[ÊE] *Ph[êe] *S[ôo]","[ÊE]PS[ÔO]"], "Phi Líp": ["Phi *L[íi]p"], "Cô Lô Se": ["C[ôo] *L[ôo] *Se","CL[ÔO]*Se"], "1 Tê Sa Lô Ni Ca": ["1 *Tê *Sa *L[ôo] *Ni *Ca","1 *TSLN[ÔO]Ca","1 TSLNCa"], "2 Tê Sa Lô Ni Ca": ["2 TSLNCa","2 *Tê *Sa *L[ôo] *Ni *Ca","2 *TSLN[ÔO]Ca"], "1 Ti Mô Thê": ["1 *Ti *Mô *Th[êe]","1 *TMTh[ÊE]"], "2 Ti Mô Thê": ["2 *Ti *Mô *Th[êe]","2 *TMTh[ÊE]"], "Tít": ["T[íi]t"], "Phi Lê Môn": ["Phi *L[êe] *Môn","PL[ÊE]M[ÔO]n","PLM[oô]n"], "Hê Bơ Rơ": ["H[êe] *Bơ *Rơ","HBR[ƠO]"], "Gia Cơ": ["GLTi", "Gia *C[ơo]"], "1 Phi E Rơ": ["1 *Phi *E *R[ơo]","1 *PER[ƠO]"], "2 Phi E Rơ": ["2 *Phi *E *R[ơo]","2 *PER[ƠO]"], "1 Giăng": ["1 *Gio*[ăa]ng*"], "2 Giăng": ["2 *Gio*[ăa]ng*"], "3 Giăng": ["3 *Gio*[ăa]ng*"], "Giu Đe": ["Giu *[ĐD]e"], "Khải Huyền": ["Kh[ảa]i *Huy[ềe]n","KHuy[ềe]n"], "1 Nê Phi": ["1 *N[êe] *Phi"], "2 Nê Phi": ["2 *N[êe] *Phi"], "Gia Cốp": ["Gi*a* *C[ốo]p"], "Ê Nót": ["[ÊE] *N[óo]t"], "Gia Rôm": ["Gi*a* *R[ôo]m"], "Ôm Ni": ["[ÔO]m *Ni"], "Lời Mặc Môn": ["L[ờo]i *M[ặa]c *M[ôo]n","LMM[ÔO]n"], "Mô Si A": ["M[ôo] *Si *A"], "An Ma": ["An *Ma"], "Hê La Man": ["H[êe]* *La* *Man"], "3 Nê Phi": ["3 *N[êe] *Phi"], "4 Nê Phi": ["4 *N[êe] *Phi"], "Mặc Môn": ["M[ậa]c *M[ôo]n", "MM[ÔO]n"], "Ê The": ["[ÊE] *The"], "Mô Rô Ni": ["M[ôo] *R[ôo] *Ni","MRN[ÎI]"], "Giáo Lý và Giao Ước": ["Gi[áa]o *L[ýi] *v[àa] *Giao *[ƯU][ớo]c","GLG[ƯU]"], "Môi Se": ["M[ôo]i *Se"], "Áp Ra Ham": ["[ÁA]p *Ra *Ham","ARH[ÂA]m"], "Joseph Smith—Ma Thi Ơ": ["Joseph *Smith—Ma *Thi *[ƠO]", "JS—MT[ƠO]"], "Joseph Smith—Lịch Sử": ["Joseph *Smith—L[ịi]ch *S[ửu]", "JS—LS"], "Những Tín Điều": ["Nh[ữu]ng *T[íi]n *[ĐD]i[ềe]u", "NT[ĐD]"]
292
+ "Sáng Thế": ["STK[yý]*", "Sáng Thế Ký","S[áa]ng[ -]*Th[ếe][ -]*(K[yý])*"], "Xuất Ê Díp Tô": ["X[ÊE]DT(K[ýy])*","X[úu]at[ -]*Ê[ -]*D[íi]p[ -]*T[ôo][ -]*(K[yý])*","Xu[ấa]t h[àa]nh[ -]*(k[yý])*"], "Lê Vi": ["L[êe][ -]*Vi[ -]*(K[yý])*","LV(K[ýy])*"], "Dân Số": ["DS(K[yý])*","D[âa]n[ -]*S[ốo][ -]*(K[yý])*"], "Phục Truyền Luật Lệ": ["PTLL(K[yý])*","Ph[úu]c[ -]*Truy[ềe]n[ -]*Lu[ậa]t[ -]*L[ệe][ -]*(K[yý])*"], "Giô Suê": ["Gi[ôo][ -]*Su[êe]"], "Các Quan Xét": ["C[áa]c[ -]*Quan[ -]*X[ée]t","QX[ée]t"], "Ru Tơ": ["Ru[ -]*T[ơo]"], "1 Sa Mu Ên": ["1[ -]*Sa[ -]*Mu[ -]*Ên","1[ -]*SM[EÊ]n"], "2 Sa Mu Ên": ["2[ -]*Sa[ -]*Mu[ -]*Ên","2[ -]*SM[EÊ]n"], "1 Các Vua": ["1[ -]*C[áa]c[ -]*Vua","1[ -]*Vua"], "2 Các Vua": ["2[ -]*C[áa]c[ -]*Vua","2[ -]*Vua"], "1 Sử Ký": ["1[ -]*S[ửu][ -]*K[yý]"], "2 Sử Ký": ["2[ -]*S[ửu][ -]*K[yý]"], "E Xơ Ra": ["E[ -]*X[ơo][ -]*Ra"], "Nê Hê Mi": ["N[êe][ -]*H[êe][ -]*Mi"], "Ê Xơ Tê": ["Ê[ -]*X[ơo][ -]*T[êe]"], "Gióp": ["Gi[óo]p"], "Thi Thiên": ["Th*i*[ -]*Thi[êe]n"], "Châm Ngôn": ["Ch[âa]m[ -]*Ng[ôo]n","CNg[ôo]n"], "Truyền Đạo": ["T[DĐ][aạ]o","Truy[ềe]n[ -]*[ĐD]a[ọo]"], "Nhã Ca": ["Nh[ãa][ -]*Ca"], "Ê Sai": ["[ÊE][ -]*Sai"], "Giê Rê Mi": ["GRMi","Gi[êe][ -]*R[êe][ -]*Mi"], "Ca Thương": ["CTh[uư][oơ]ng","Ca[ -]*Th[ưu]ng"], "Ê Xê Chi Ên": ["[EÊ]XC[EÊ]n","Ê[ -]*X[êe][ -]*Chi[ -]*[ÊE]n"], "Đa Ni Ên": ["[DĐ]N[EÊ]n","[ĐD]a[ -]*Ni[ -]*[ÊE]n"], "Ô Sê": ["[ÔO][ -]*S[êe]"], "Giô Ên": ["Gi[ôo][ -]*[ÊE]n"], "A Mốt": ["A[ -]*M[ốo]t"], "Áp Đia": ["[ÁA]p[ -]*Đia"], "Giô Na": ["Gi[ôo][ -]*Na"], "Mi Chê": ["Mi[ -]*Ch[êe]"], "Na Hum": ["Na[ -]*Hum"], "Ha Ba Cúc": ["HBCuc","Ha[ -]*Ba[ -]*C[úu]c"], "Sô Phô Ni": ["S[ôo]*[ -]*Ph*[ôo]*[ -]*Ni"], "A Ghê": ["A[ -]*Gh[êe]"], "Xa Cha Ri": ["Xa*[ -]*Ch*a*[ -]*Ri"], "Ma La Chi": ["Ma*[ -]*La*[ -]*Chi"],
293
+ "Ma Thi Ơ": ["Ma[ -]*Thi[ -]*[ƠO]","MT[OƠ]"], "Mác": ["M[áa]c"], "Lu Ca": ["Lu[ -]*Ca"], "Giăng": ["Gio*[ăa]ng*"], "Công Vụ Các Sứ Đồ": ["C[ôo]ng[ -]*Vụ[ -]*C[áa]c[ -]*Sứ[ -]*Đ[ồo]", "CVCS[ĐD]"], "Rô Ma": ["R[ôo][ -]*Ma"], "1 Cô Rinh Tô": ["1[ -]*C[ôo]*[ -]*Ri*n*h*[ -]*T[ôo]"], "2 Cô Rinh Tô": ["2[ -]*C[ôo]*[ -]*Ri*n*h*[ -]*T[ôo]"], "Ga La Ti": ["Ga[ -]*La[ -]*Ti"], "Ê Phê Sô": ["[ÊE][ -]*Ph[êe][ -]*S[ôo]","[ÊE]PS[ÔO]"], "Phi Líp": ["Phi[ -]*L[íi]p"], "Cô Lô Se": ["C[ôo][ -]*L[ôo][ -]*Se","CL[ÔO]*Se"], "1 Tê Sa Lô Ni Ca": ["1[ -]*Tê[ -]*Sa[ -]*L[ôo][ -]*Ni[ -]*Ca","1[ -]*TSLN[ÔO]Ca","1 TSLNCa"], "2 Tê Sa Lô Ni Ca": ["2 TSLNCa","2[ -]*Tê[ -]*Sa[ -]*L[ôo][ -]*Ni[ -]*Ca","2[ -]*TSLN[ÔO]Ca"], "1 Ti Mô Thê": ["1[ -]*Ti[ -]*Mô[ -]*Th[êe]","1[ -]*TMTh[ÊE]"], "2 Ti Mô Thê": ["2[ -]*Ti[ -]*Mô[ -]*Th[êe]","2[ -]*TMTh[ÊE]"], "Tít": ["T[íi]t"], "Phi Lê Môn": ["Phi[ -]*L[êe][ -]*Môn","PL[ÊE]M[ÔO]n","PLM[oô]n"], "Hê Bơ Rơ": ["H[êe][ -]*Bơ[ -]*Rơ","HBR[ƠO]"], "Gia Cơ": ["GLTi", "Gia[ -]*C[ơo]"], "1 Phi E Rơ": ["1[ -]*Phi[ -]*E[ -]*R[ơo]","1[ -]*PER[ƠO]"], "2 Phi E Rơ": ["2[ -]*Phi[ -]*E[ -]*R[ơo]","2[ -]*PER[ƠO]"], "1 Giăng": ["1[ -]*Gio*[ăa]ng*"], "2 Giăng": ["2[ -]*Gio*[ăa]ng*"], "3 Giăng": ["3[ -]*Gio*[ăa]ng*"], "Giu Đe": ["Giu[ -]*[ĐD]e"], "Khải Huyền": ["Kh[ảa]i[ -]*Huy[ềe]n","KHuy[ềe]n"], "1 Nê Phi": ["1[ -]*N[êe][ -]*Phi"], "2 Nê Phi": ["2[ -]*N[êe][ -]*Phi"], "Gia Cốp": ["Gi*a*[ -]*C[ốo]p"], "Ê Nót": ["[ÊE][ -]*N[óo]t"], "Gia Rôm": ["Gi*a*[ -]*R[ôo]m"], "Ôm Ni": ["[ÔO]m[ -]*Ni"], "Lời Mặc Môn": ["L[ờo]i[ -]*M[ặa]c[ -]*M[ôo]n","LMM[ÔO]n"], "Mô Si A": ["M[ôo][ -]*Si[ -]*A"], "An Ma": ["An[ -]*Ma"], "Hê La Man": ["H[êe]*[ -]*La*[ -]*Man"], "3 Nê Phi": ["3[ -]*N[êe][ -]*Phi"], "4 Nê Phi": ["4[ -]*N[êe][ -]*Phi"], "Mặc Môn": ["M[ậa]c[ -]*M[ôo]n", "MM[ÔO]n"], "Ê The": ["[ÊE][ -]*The"], "Mô Rô Ni": ["M[ôo][ -]*R[ôo][ -]*Ni","MRN[ÎI]"], "Giáo Lý và Giao Ước": ["Gi[áa]o[ -]*L[ýi][ -]*v[àa][ -]*Giao[ -]*[ƯU][ớo]c","GLG[ƯU]"], "Môi Se": ["M[ôo]i[ -]*Se"], "Áp Ra Ham": ["[ÁA]p[ -]*Ra[ -]*Ham","ARH[ÂA]m"], "Joseph Smith—Ma Thi Ơ": ["Joseph[ -]*Smith—Ma[ -]*Thi[ -]*[ƠO]", "JS—MT[ƠO]"], "Joseph Smith—Lịch Sử": ["Joseph[ -]*Smith—L[ịi]ch[ -]*S[ửu]", "JS—LS"], "Những Tín Điều": ["Nh[ữu]ng[ -]*T[íi]n[ -]*[ĐD]i[ềe]u", "NT[ĐD]"]
294
294
  },
295
295
  matchRules:{
296
296
  book: `(Thứ nhất|I|1|Thứ hai|II|2|Thứ ba|III|3|Thứ tư|IV|4)*\\s*(Sách* của)*\\s*`,
@@ -647,26 +647,59 @@ const raw_lang = {
647
647
  }
648
648
  ;
649
649
  const findMatchingBooks = (content,books) => {
650
- const matchingBooks = books.filter(i=>(new RegExp(i,"ig")).test(content));
650
+ const matchingBooks = books.filter(book => {
651
+ try {
652
+ // For Vietnamese and other languages, handle more flexible matching
653
+ let pattern = book;
654
+
655
+ // Replace * with optional space/separator patterns
656
+ pattern = pattern.replace(/\*/g, '');
657
+
658
+ // Make separators very flexible - handle spaces, hyphens, dots, etc.
659
+ pattern = pattern.replace(/[\s\-–—\.]+/g, '[\\s\\-–—\\.]*');
660
+
661
+ const regex = new RegExp(pattern, "ig");
662
+ const result = regex.test(content);
663
+
664
+ return result;
665
+ } catch (e) {
666
+ // Fallback to original logic if regex fails
667
+ return (new RegExp(book,"ig")).test(content);
668
+ }
669
+ });
651
670
  return matchingBooks;
652
671
  }
653
672
 
654
673
  const findMatches = (content,books,lang_extra) => {
674
+ // Pre-process content to normalize HTML entities to Unicode dashes
675
+ const htmlEntityMap = {
676
+ '&ndash;': '–',
677
+ '&mdash;': '—',
678
+ '&minus;': '–', // Treat minus as en dash for scripture ranges
679
+ '&#8211;': '–',
680
+ '&#8212;': '—',
681
+ '&#8722;': '–' // Treat minus as en dash for scripture ranges
682
+ };
683
+
684
+ let normalizedContent = content;
685
+ Object.entries(htmlEntityMap).forEach(([entity, unicode]) => {
686
+ normalizedContent = normalizedContent.replace(new RegExp(entity, 'g'), unicode);
687
+ });
655
688
 
656
689
  const tail = lang_extra.tail ? new RegExp(lang_extra.tail,"ig") : /[^0-9]+$/;
657
690
  const preBookMatch = lang_extra.book || `(First|I|1|1st|Second|II|2|2nd|Third|III|3|3rd|Fourth|IV|4|4th)*\\s*(books* of)*\\s*`;
658
- const matchingBooks = findMatchingBooks(content,books);
659
- const postBookMatch = lang_extra.chapter || "([0-9:.;,~ —–-]|cf|(?:&ndash;))*[0-9]+";
660
- const fullBookMatches = matchingBooks.map(bookMatch=>{
691
+ const matchingBooks = findMatchingBooks(normalizedContent,books);
692
+ const postBookMatch = lang_extra.chapter || "([0-9:.;,~ —–-]|cf)*[0-9]+";
693
+ const fullBookMatches = matchingBooks.map(bookMatch=>{
661
694
  const patternString = preBookMatch + bookMatch ;
662
695
  const pattern = (new RegExp(patternString,"ig"));
663
- const stringMatch = pattern.test(content) ? patternString : null;
696
+ const stringMatch = pattern.test(normalizedContent) ? patternString : null;
664
697
  //console.log({pattern,content,stringMatch});
665
698
  return stringMatch;
666
699
  }).filter(x=>!!x);
667
700
 
668
701
  const bookSubStrings = fullBookMatches.map(bookMatch=>{
669
- const substrings = content.match(new RegExp(bookMatch,"ig")).flat();
702
+ const substrings = normalizedContent.match(new RegExp(bookMatch,"ig")).flat();
670
703
  return substrings;
671
704
  }).flat().reduce((prev,current)=>{
672
705
  if(prev.includes(current)) return prev;
@@ -674,13 +707,13 @@ const fullBookMatches = matchingBooks.map(bookMatch=>{
674
707
  },[]).filter(i=>!!i).map(substring=>{
675
708
  substring = substring.trim();
676
709
  let positions = [];
677
- let index = content.indexOf(substring);
710
+ let index = normalizedContent.indexOf(substring);
678
711
  while (index != -1) {
679
712
  positions.push(index);
680
- index = content.indexOf(substring, index + 1);
713
+ index = normalizedContent.indexOf(substring, index + 1);
681
714
  } return [substring,positions];
682
715
  }).map(([substring,positions])=>{
683
- const preChars = positions.map(i=>content.substring(i-1,i));
716
+ const preChars = positions.map(i=>normalizedContent.substring(i-1,i));
684
717
  positions = positions.filter((i,index)=>{
685
718
  const charRightBeforeMatch = preChars[index];
686
719
  const leadingCharIsInvalid = !/^(\s|\W|)$/.test(charRightBeforeMatch);
@@ -698,7 +731,7 @@ const fullBookMatches = matchingBooks.map(bookMatch=>{
698
731
  }catch(e){
699
732
  return null;
700
733
  }
701
- const match = content.slice(i).match(pattern)?.[0]?.replace(tail,"").trim();
734
+ const match = normalizedContent.slice(i).match(pattern)?.[0]?.replace(tail,"").trim();
702
735
  if(!match) return null;
703
736
  const len = match.length;
704
737
  const pos = i;
@@ -711,12 +744,12 @@ const fullBookMatches = matchingBooks.map(bookMatch=>{
711
744
  const overLappingItems = possiblyOverlappingMatches.filter(([s,s1,e1])=>s!==string && s1<end && e1>end);
712
745
  const hasOverlap = overLappingItems.length > 0;
713
746
  const newEnd = hasOverlap ? Math.min(...overLappingItems.map(([s,s1,e1])=>s1)) : end;
714
- const newString = content.slice(start,newEnd);
747
+ const newString = normalizedContent.slice(start,newEnd);
715
748
  return newString.replace(tail,"").trim();
716
749
  }).filter(i=>!!i);
717
750
  const matches = matchesWithReferences.map(string=>{
718
751
  const pattern = (new RegExp(string,"ig"));
719
- const matches = content.match(pattern)?.map(i=>i.trim().replace(tail,""));
752
+ const matches = normalizedContent.match(pattern)?.map(i=>i.trim().replace(tail,""));
720
753
  //console.log({string,matches,tail});
721
754
  return matches;
722
755
  }).flat()
@@ -724,7 +757,7 @@ const fullBookMatches = matchingBooks.map(bookMatch=>{
724
757
  if(prev.includes(current)) return prev;
725
758
  return [...prev,current]
726
759
  },[]).filter(i=>!!i);
727
- return matches;
760
+ return {matches, normalizedContent};
728
761
  }
729
762
 
730
763
 
@@ -816,8 +849,8 @@ const processReferenceDetection = (content,books,lang_extra,lookupReference,call
816
849
  {
817
850
  try{
818
851
  lang_extra = lang_extra || {};
819
- const matches = findMatches(content,books,lang_extra);
820
- const matchIndeces = findMatchIndexes(content,matches,lookupReference,lang_extra);
852
+ const {matches, normalizedContent} = findMatches(content,books,lang_extra);
853
+ const matchIndeces = findMatchIndexes(normalizedContent,matches,lookupReference,lang_extra);
821
854
  if(!matchIndeces) return content;
822
855
  const gapsBetweenIndeces = matchIndeces.reduce((prev,current,index)=>{
823
856
  if(index === 0) return prev;
@@ -825,7 +858,7 @@ const processReferenceDetection = (content,books,lang_extra,lookupReference,call
825
858
  const gap = [lastPair[1],current[0]];
826
859
  return [...prev,gap];
827
860
  },[]);
828
- const gapStrings = gapsBetweenIndeces.map(([start,end])=>content.substring(start,end).trim());
861
+ const gapStrings = gapsBetweenIndeces.map(([start,end])=>normalizedContent.substring(start,end).trim());
829
862
  //console.log({matches,matchIndeces,gapsBetweenIndeces,gapStrings});
830
863
  const joiners = lang_extra.joiners || ["^[;, ]*(and|c\\.*f\\.*)*$"];
831
864
  const gapThatMayBeMerged = gapsBetweenIndeces.map(([start,end],i)=>{
@@ -874,11 +907,11 @@ const processReferenceDetection = (content,books,lang_extra,lookupReference,call
874
907
 
875
908
  //check content between matches. If puctuation only (or 'and'), then merge
876
909
  const cutItems = mergedIndeces.map(([start,end])=>{
877
- const string = content.substring(start,end);
910
+ const string = normalizedContent.substring(start,end);
878
911
  return lookupReference(string).query
879
912
  }).map(callback);
880
913
 
881
- const negativeItems = negativeSpace.map(([start,end])=>content.substring(start,end));
914
+ const negativeItems = negativeSpace.map(([start,end])=>normalizedContent.substring(start,end));
882
915
  const firstReferenceIsAtStart = mergedIndeces[0][0] === 0;
883
916
  const maxCount = Math.max(cutItems.length,negativeItems.length);
884
917
  //merge by alternating cutItems and negativeItems. run the callback on the cut items
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripture-guide",
3
- "version": "1.0.81",
3
+ "version": "1.0.82",
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",