bible-ref-parse 3.3.0 → 3.3.1

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.
Files changed (128) hide show
  1. package/dist/am-bcv-parser.js +122 -11
  2. package/dist/am-bcv-parser.min.js +1 -1
  3. package/dist/ar-bcv-parser.js +122 -11
  4. package/dist/ar-bcv-parser.min.js +2 -2
  5. package/dist/bb-bcv-parser.js +122 -11
  6. package/dist/bb-bcv-parser.min.js +2 -2
  7. package/dist/bg-bcv-parser.js +122 -11
  8. package/dist/bg-bcv-parser.min.js +2 -2
  9. package/dist/bn-bcv-parser.js +122 -11
  10. package/dist/bn-bcv-parser.min.js +2 -2
  11. package/dist/ceb-bcv-parser.js +122 -11
  12. package/dist/ceb-bcv-parser.min.js +2 -2
  13. package/dist/cs-bcv-parser.js +122 -11
  14. package/dist/cs-bcv-parser.min.js +2 -2
  15. package/dist/da-bcv-parser.js +122 -11
  16. package/dist/da-bcv-parser.min.js +2 -2
  17. package/dist/de-bcv-parser.js +122 -11
  18. package/dist/de-bcv-parser.min.js +1 -1
  19. package/dist/ee-bcv-parser.js +122 -11
  20. package/dist/ee-bcv-parser.min.js +2 -2
  21. package/dist/el-bcv-parser.js +122 -11
  22. package/dist/el-bcv-parser.min.js +1 -1
  23. package/dist/en-bcv-parser.js +122 -11
  24. package/dist/en-bcv-parser.min.js +2 -2
  25. package/dist/es-bcv-parser.js +122 -11
  26. package/dist/es-bcv-parser.min.js +1 -1
  27. package/dist/fa-bcv-parser.js +122 -11
  28. package/dist/fa-bcv-parser.min.js +2 -2
  29. package/dist/fi-bcv-parser.js +122 -11
  30. package/dist/fi-bcv-parser.min.js +2 -2
  31. package/dist/fr-bcv-parser.js +122 -11
  32. package/dist/fr-bcv-parser.min.js +2 -2
  33. package/dist/he-bcv-parser.js +122 -11
  34. package/dist/he-bcv-parser.min.js +1 -1
  35. package/dist/hi-bcv-parser.js +122 -11
  36. package/dist/hi-bcv-parser.min.js +2 -2
  37. package/dist/hl-bcv-parser.js +122 -11
  38. package/dist/hl-bcv-parser.min.js +2 -2
  39. package/dist/hr-bcv-parser.js +122 -11
  40. package/dist/hr-bcv-parser.min.js +2 -2
  41. package/dist/ht-bcv-parser.js +122 -11
  42. package/dist/ht-bcv-parser.min.js +2 -2
  43. package/dist/hu-bcv-parser.js +122 -11
  44. package/dist/hu-bcv-parser.min.js +2 -2
  45. package/dist/id-bcv-parser.js +122 -11
  46. package/dist/id-bcv-parser.min.js +2 -2
  47. package/dist/il-bcv-parser.js +122 -11
  48. package/dist/il-bcv-parser.min.js +2 -2
  49. package/dist/is-bcv-parser.js +122 -11
  50. package/dist/is-bcv-parser.min.js +2 -2
  51. package/dist/it-bcv-parser.js +122 -11
  52. package/dist/it-bcv-parser.min.js +2 -2
  53. package/dist/ja-bcv-parser.js +122 -11
  54. package/dist/ja-bcv-parser.min.js +2 -2
  55. package/dist/jv-bcv-parser.js +122 -11
  56. package/dist/jv-bcv-parser.min.js +2 -2
  57. package/dist/ko-bcv-parser.js +122 -11
  58. package/dist/ko-bcv-parser.min.js +2 -2
  59. package/dist/la-bcv-parser.js +122 -11
  60. package/dist/la-bcv-parser.min.js +2 -2
  61. package/dist/lu-bcv-parser.js +122 -11
  62. package/dist/lu-bcv-parser.min.js +2 -2
  63. package/dist/mg-bcv-parser.js +122 -11
  64. package/dist/mg-bcv-parser.min.js +2 -2
  65. package/dist/mk-bcv-parser.js +122 -11
  66. package/dist/mk-bcv-parser.min.js +1 -1
  67. package/dist/mq-bcv-parser.js +122 -11
  68. package/dist/mq-bcv-parser.min.js +2 -2
  69. package/dist/mr-bcv-parser.js +122 -11
  70. package/dist/mr-bcv-parser.min.js +1 -1
  71. package/dist/nd-bcv-parser.js +122 -11
  72. package/dist/nd-bcv-parser.min.js +1 -1
  73. package/dist/ne-bcv-parser.js +122 -11
  74. package/dist/ne-bcv-parser.min.js +2 -2
  75. package/dist/nl-bcv-parser.js +122 -11
  76. package/dist/nl-bcv-parser.min.js +2 -2
  77. package/dist/no-bcv-parser.js +122 -11
  78. package/dist/no-bcv-parser.min.js +1 -1
  79. package/dist/ny-bcv-parser.js +122 -11
  80. package/dist/ny-bcv-parser.min.js +2 -2
  81. package/dist/or-bcv-parser.js +122 -11
  82. package/dist/or-bcv-parser.min.js +2 -2
  83. package/dist/pa-bcv-parser.js +122 -11
  84. package/dist/pa-bcv-parser.min.js +2 -2
  85. package/dist/pl-bcv-parser.js +122 -11
  86. package/dist/pl-bcv-parser.min.js +2 -2
  87. package/dist/pt-bcv-parser.js +122 -11
  88. package/dist/pt-bcv-parser.min.js +1 -1
  89. package/dist/ro-bcv-parser.js +122 -11
  90. package/dist/ro-bcv-parser.min.js +2 -2
  91. package/dist/ru-bcv-parser.js +122 -11
  92. package/dist/ru-bcv-parser.min.js +2 -2
  93. package/dist/rw-bcv-parser.js +122 -11
  94. package/dist/rw-bcv-parser.min.js +3 -3
  95. package/dist/si-bcv-parser.js +122 -11
  96. package/dist/si-bcv-parser.min.js +2 -2
  97. package/dist/sk-bcv-parser.js +122 -11
  98. package/dist/sk-bcv-parser.min.js +2 -2
  99. package/dist/so-bcv-parser.js +122 -11
  100. package/dist/so-bcv-parser.min.js +2 -2
  101. package/dist/sq-bcv-parser.js +122 -11
  102. package/dist/sq-bcv-parser.min.js +2 -2
  103. package/dist/sr-bcv-parser.js +122 -11
  104. package/dist/sr-bcv-parser.min.js +2 -2
  105. package/dist/sv-bcv-parser.js +122 -11
  106. package/dist/sv-bcv-parser.min.js +2 -2
  107. package/dist/sw-bcv-parser.js +122 -11
  108. package/dist/sw-bcv-parser.min.js +2 -2
  109. package/dist/ta-bcv-parser.js +122 -11
  110. package/dist/ta-bcv-parser.min.js +2 -2
  111. package/dist/test/en.spec.js +7 -0
  112. package/dist/th-bcv-parser.js +122 -11
  113. package/dist/th-bcv-parser.min.js +1 -1
  114. package/dist/tl-bcv-parser.js +122 -11
  115. package/dist/tl-bcv-parser.min.js +2 -2
  116. package/dist/tr-bcv-parser.js +122 -11
  117. package/dist/tr-bcv-parser.min.js +2 -2
  118. package/dist/uk-bcv-parser.js +122 -11
  119. package/dist/uk-bcv-parser.min.js +2 -2
  120. package/dist/ur-bcv-parser.js +122 -11
  121. package/dist/ur-bcv-parser.min.js +2 -2
  122. package/dist/vi-bcv-parser.js +122 -11
  123. package/dist/vi-bcv-parser.min.js +1 -1
  124. package/dist/zh-bcv-parser.js +122 -11
  125. package/dist/zh-bcv-parser.min.js +3 -3
  126. package/dist/zu-bcv-parser.js +122 -11
  127. package/dist/zu-bcv-parser.min.js +2 -2
  128. package/package.json +1 -1
@@ -569,6 +569,28 @@ class bcv_parser {
569
569
  if (entity.passages == null) {
570
570
  continue;
571
571
  }
572
+ if (this.options.consecutive_combination_strategy === "separate-chapters") {
573
+ const semicolon_segments = this.split_text_by_semicolon(entity.absolute_indices);
574
+ if (semicolon_segments.length > 1) {
575
+ for (const segment of Array.from(semicolon_segments)) {
576
+ const sub_parser = new bcv_parser;
577
+ sub_parser.set_options({ ...this.options });
578
+ sub_parser.parse(segment.text);
579
+ for (const sub of Array.from(sub_parser.parsed_entities())) {
580
+ if (sub.osis.length === 0) {
581
+ continue;
582
+ }
583
+ const indices = [sub.indices[0] + segment.offset, sub.indices[1] + segment.offset];
584
+ const entry = { osis: sub.osis, translations: sub.translations, indices, entity_id };
585
+ if (sub.osises != null) {
586
+ entry.osises = sub.osises;
587
+ }
588
+ out.push(entry);
589
+ }
590
+ }
591
+ continue;
592
+ }
593
+ }
572
594
  if (((entity.type === "b") && (this.options.book_alone_strategy === "ignore")) || ((entity.type === "b_range") && (this.options.book_range_strategy === "ignore")) || (entity.type === "context")) {
573
595
  continue;
574
596
  }
@@ -618,10 +640,9 @@ class bcv_parser {
618
640
  passage.absolute_indices = entity.absolute_indices;
619
641
  }
620
642
  if ((this.options.consecutive_combination_strategy === 'separate-chapters') && (passage.start.c !== passage.end.c)) {
621
- const osises_by_chapter = this.get_osises_by_chapter({ osis: "", start: passage.start, end: passage.end }, translation_alias);
622
643
  osises.push({
623
644
  osis: passage.valid.valid ? this.to_osis(passage.start, passage.end, translation_alias) : "",
624
- osises: osises_by_chapter,
645
+ osises: this.get_osises_by_chapter({ osis: "", start: passage.start, end: passage.end }, translation_alias),
625
646
  type: passage.type,
626
647
  indices: passage.absolute_indices,
627
648
  translations,
@@ -673,6 +694,37 @@ class bcv_parser {
673
694
  // Add the OSIS string and some data to the array.
674
695
  }
675
696
  else {
697
+ if ((this.options.consecutive_combination_strategy === "separate-chapters") && (entity.type === "sequence")) {
698
+ const groups = this.group_osises_by_semicolon(osises);
699
+ if (groups.length > 1) {
700
+ for (const group of Array.from(groups)) {
701
+ if (group.length === 0) {
702
+ continue;
703
+ }
704
+ const group_last_i = group.length - 1;
705
+ const indices = [group[0].indices[0], group[group_last_i].indices[1]];
706
+ if ((group[group_last_i].enclosed_indices != null) && (group[group_last_i].enclosed_indices[1] >= 0)) {
707
+ indices[1] = group[group_last_i].enclosed_indices[1];
708
+ }
709
+ const strings = [];
710
+ let osises_by_chapter = [];
711
+ for (osis of Array.from(group)) {
712
+ if (osis.osis.length > 0) {
713
+ strings.push(osis.osis);
714
+ }
715
+ if (osis.osises != null) {
716
+ osises_by_chapter = osises_by_chapter.concat(osis.osises);
717
+ }
718
+ }
719
+ const out_entry = { osis: strings.join(","), indices, translations, entity_id, entities: group };
720
+ if (osises_by_chapter.length > 0) {
721
+ out_entry.osises = osises_by_chapter;
722
+ }
723
+ out.push(out_entry);
724
+ }
725
+ continue;
726
+ }
727
+ }
676
728
  var osis;
677
729
  var strings = [];
678
730
  var last_i = osises.length - 1;
@@ -688,15 +740,9 @@ class bcv_parser {
688
740
  let osises_by_chapter = [];
689
741
  if (this.options.consecutive_combination_strategy === "separate-chapters") {
690
742
  for (osis of Array.from(osises)) {
691
- if (osis.osis.length === 0) {
692
- continue;
693
- }
694
743
  if (osis.osises != null) {
695
744
  osises_by_chapter = osises_by_chapter.concat(osis.osises);
696
745
  }
697
- else {
698
- osises_by_chapter = osises_by_chapter.concat(this.get_osises_by_chapter(osis, translation_alias));
699
- }
700
746
  }
701
747
  }
702
748
  const out_entry = { osis: strings.join(","), indices: entity.absolute_indices, translations, entity_id, entities: osises };
@@ -784,14 +830,14 @@ class bcv_parser {
784
830
  return out;
785
831
  }
786
832
  get_osises_by_chapter(passage, translation) {
787
- if ((passage == null) || (passage.start == null) || (passage.end == null) || (passage.osis == null)) {
833
+ if ((passage == null) || (passage.start == null) || (passage.end == null)) {
788
834
  return [];
789
835
  }
790
836
  if ((passage.start.b == null) || (passage.end.b == null) || (passage.start.c == null) || (passage.end.c == null)) {
791
- return passage.osis.length > 0 ? [passage.osis] : [];
837
+ return (passage.osis != null) && (passage.osis.length > 0) ? [passage.osis] : [];
792
838
  }
793
839
  if ((passage.start.b !== passage.end.b) || (passage.start.c === passage.end.c)) {
794
- return passage.osis.length > 0 ? [passage.osis] : [];
840
+ return (passage.osis != null) && (passage.osis.length > 0) ? [passage.osis] : [];
795
841
  }
796
842
  const out = [];
797
843
  for (let c = passage.start.c, end = passage.end.c, asc = passage.start.c <= end; asc ? c <= end : c >= end; asc ? c++ : c--) {
@@ -813,6 +859,66 @@ class bcv_parser {
813
859
  }
814
860
  return out;
815
861
  }
862
+ get_separator_between(prev_indices, next_indices) {
863
+ if ((this.s == null) || (prev_indices == null) || (next_indices == null)) {
864
+ return "";
865
+ }
866
+ const start = prev_indices[1] + 1;
867
+ const end = next_indices[0];
868
+ if (end <= start) {
869
+ return "";
870
+ }
871
+ return this.s.slice(start, end);
872
+ }
873
+ has_semicolon_separator(prev_osis, next_osis) {
874
+ const between = this.get_separator_between(prev_osis.indices, next_osis.indices);
875
+ return /[;;]/.test(between);
876
+ }
877
+ group_osises_by_semicolon(osises) {
878
+ const out = [];
879
+ let current = [];
880
+ for (const osis of Array.from(osises)) {
881
+ if (current.length === 0) {
882
+ current.push(osis);
883
+ continue;
884
+ }
885
+ if (this.has_semicolon_separator(current[current.length - 1], osis)) {
886
+ out.push(current);
887
+ current = [osis];
888
+ }
889
+ else {
890
+ current.push(osis);
891
+ }
892
+ }
893
+ if (current.length > 0) {
894
+ out.push(current);
895
+ }
896
+ return out;
897
+ }
898
+ split_text_by_semicolon(absolute_indices) {
899
+ if ((this.s == null) || (absolute_indices == null) || (absolute_indices[0] == null) || (absolute_indices[1] == null)) {
900
+ return [];
901
+ }
902
+ const text = this.s.slice(absolute_indices[0], absolute_indices[1]);
903
+ if (!/[;;]/.test(text)) {
904
+ return [{ text, offset: absolute_indices[0] }];
905
+ }
906
+ const segments = [];
907
+ let start = 0;
908
+ for (let i = 0, end = text.length; i < end; i++) {
909
+ const ch = text[i];
910
+ if ((ch === ";") || (ch === ";")) {
911
+ if (i > start) {
912
+ segments.push({ text: text.slice(start, i), offset: absolute_indices[0] + start });
913
+ }
914
+ start = i + 1;
915
+ }
916
+ }
917
+ if (start < text.length) {
918
+ segments.push({ text: text.slice(start), offset: absolute_indices[0] + start });
919
+ }
920
+ return segments;
921
+ }
816
922
  // If we want to treat Ps151 as a book rather than a chapter, we have to do some gymnastics to make sure it returns properly.
817
923
  fix_ps151(start, end, translation) {
818
924
  // Ps151 doesn't necessarily get promoted into the translation chapter list because during the string parsing, we treat it as `Ps` rather than `Ps151`.
@@ -857,6 +963,11 @@ class bcv_parser {
857
963
  if (osis.osis.length > 0) {
858
964
  var prev_i = out.length - 1;
859
965
  var is_enclosed_last = false;
966
+ if ((prev_i >= 0) && this.has_semicolon_separator(out[prev_i], osis)) {
967
+ out.push(osis);
968
+ prev = { b: osis.end.b, c: osis.end.c, v: osis.end.v };
969
+ continue;
970
+ }
860
971
  // Record the start index of the enclosed sequence for use in future iterations.
861
972
  if (osis.enclosed_indices[0] !== enclosed_sequence_start) {
862
973
  enclosed_sequence_start = osis.enclosed_indices[0];