bible-ref-parse 3.2.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.
- package/dist/am-bcv-parser.js +191 -32
- package/dist/am-bcv-parser.min.js +1 -1
- package/dist/ar-bcv-parser.js +191 -32
- package/dist/ar-bcv-parser.min.js +2 -2
- package/dist/bb-bcv-parser.js +191 -32
- package/dist/bb-bcv-parser.min.js +2 -2
- package/dist/bg-bcv-parser.js +191 -32
- package/dist/bg-bcv-parser.min.js +2 -2
- package/dist/bn-bcv-parser.js +191 -32
- package/dist/bn-bcv-parser.min.js +2 -2
- package/dist/ceb-bcv-parser.js +191 -32
- package/dist/ceb-bcv-parser.min.js +2 -2
- package/dist/cs-bcv-parser.js +191 -32
- package/dist/cs-bcv-parser.min.js +2 -2
- package/dist/da-bcv-parser.js +191 -32
- package/dist/da-bcv-parser.min.js +2 -2
- package/dist/de-bcv-parser.js +191 -32
- package/dist/de-bcv-parser.min.js +2 -2
- package/dist/ee-bcv-parser.js +191 -32
- package/dist/ee-bcv-parser.min.js +3 -3
- package/dist/el-bcv-parser.js +191 -32
- package/dist/el-bcv-parser.min.js +1 -1
- package/dist/en-bcv-parser.js +122 -11
- package/dist/en-bcv-parser.min.js +2 -2
- package/dist/es-bcv-parser.js +191 -32
- package/dist/es-bcv-parser.min.js +2 -2
- package/dist/fa-bcv-parser.js +191 -32
- package/dist/fa-bcv-parser.min.js +3 -3
- package/dist/fi-bcv-parser.js +191 -32
- package/dist/fi-bcv-parser.min.js +2 -2
- package/dist/fr-bcv-parser.js +191 -32
- package/dist/fr-bcv-parser.min.js +3 -3
- package/dist/he-bcv-parser.js +191 -32
- package/dist/he-bcv-parser.min.js +1 -1
- package/dist/hi-bcv-parser.js +191 -32
- package/dist/hi-bcv-parser.min.js +2 -2
- package/dist/hl-bcv-parser.js +191 -32
- package/dist/hl-bcv-parser.min.js +2 -2
- package/dist/hr-bcv-parser.js +191 -32
- package/dist/hr-bcv-parser.min.js +2 -2
- package/dist/ht-bcv-parser.js +191 -32
- package/dist/ht-bcv-parser.min.js +2 -2
- package/dist/hu-bcv-parser.js +191 -32
- package/dist/hu-bcv-parser.min.js +2 -2
- package/dist/id-bcv-parser.js +191 -32
- package/dist/id-bcv-parser.min.js +2 -2
- package/dist/il-bcv-parser.js +189 -30
- package/dist/il-bcv-parser.min.js +2 -2
- package/dist/is-bcv-parser.js +191 -32
- package/dist/is-bcv-parser.min.js +2 -2
- package/dist/it-bcv-parser.js +191 -32
- package/dist/it-bcv-parser.min.js +3 -3
- package/dist/ja-bcv-parser.js +191 -32
- package/dist/ja-bcv-parser.min.js +3 -3
- package/dist/jv-bcv-parser.js +191 -32
- package/dist/jv-bcv-parser.min.js +2 -2
- package/dist/ko-bcv-parser.js +191 -32
- package/dist/ko-bcv-parser.min.js +2 -2
- package/dist/la-bcv-parser.js +191 -32
- package/dist/la-bcv-parser.min.js +2 -2
- package/dist/lu-bcv-parser.js +191 -32
- package/dist/lu-bcv-parser.min.js +2 -2
- package/dist/mg-bcv-parser.js +191 -32
- package/dist/mg-bcv-parser.min.js +3 -3
- package/dist/mk-bcv-parser.js +191 -32
- package/dist/mk-bcv-parser.min.js +2 -2
- package/dist/mq-bcv-parser.js +191 -32
- package/dist/mq-bcv-parser.min.js +2 -2
- package/dist/mr-bcv-parser.js +191 -32
- package/dist/mr-bcv-parser.min.js +2 -2
- package/dist/nd-bcv-parser.js +191 -32
- package/dist/nd-bcv-parser.min.js +2 -2
- package/dist/ne-bcv-parser.js +191 -32
- package/dist/ne-bcv-parser.min.js +2 -2
- package/dist/nl-bcv-parser.js +191 -32
- package/dist/nl-bcv-parser.min.js +3 -3
- package/dist/no-bcv-parser.js +191 -32
- package/dist/no-bcv-parser.min.js +2 -2
- package/dist/ny-bcv-parser.js +191 -32
- package/dist/ny-bcv-parser.min.js +2 -2
- package/dist/or-bcv-parser.js +191 -32
- package/dist/or-bcv-parser.min.js +2 -2
- package/dist/pa-bcv-parser.js +191 -32
- package/dist/pa-bcv-parser.min.js +2 -2
- package/dist/pl-bcv-parser.js +191 -32
- package/dist/pl-bcv-parser.min.js +2 -2
- package/dist/pt-bcv-parser.js +191 -32
- package/dist/pt-bcv-parser.min.js +3 -3
- package/dist/ro-bcv-parser.js +191 -32
- package/dist/ro-bcv-parser.min.js +2 -2
- package/dist/ru-bcv-parser.js +191 -32
- package/dist/ru-bcv-parser.min.js +2 -2
- package/dist/rw-bcv-parser.js +191 -32
- package/dist/rw-bcv-parser.min.js +3 -3
- package/dist/si-bcv-parser.js +191 -32
- package/dist/si-bcv-parser.min.js +2 -2
- package/dist/sk-bcv-parser.js +191 -32
- package/dist/sk-bcv-parser.min.js +3 -3
- package/dist/so-bcv-parser.js +191 -32
- package/dist/so-bcv-parser.min.js +2 -2
- package/dist/sq-bcv-parser.js +191 -32
- package/dist/sq-bcv-parser.min.js +2 -2
- package/dist/sr-bcv-parser.js +191 -32
- package/dist/sr-bcv-parser.min.js +2 -2
- package/dist/sv-bcv-parser.js +191 -32
- package/dist/sv-bcv-parser.min.js +2 -2
- package/dist/sw-bcv-parser.js +191 -32
- package/dist/sw-bcv-parser.min.js +2 -2
- package/dist/ta-bcv-parser.js +191 -32
- package/dist/ta-bcv-parser.min.js +2 -2
- package/dist/test/en.spec.js +7 -0
- package/dist/th-bcv-parser.js +191 -32
- package/dist/th-bcv-parser.min.js +2 -2
- package/dist/tl-bcv-parser.js +191 -32
- package/dist/tl-bcv-parser.min.js +2 -2
- package/dist/tr-bcv-parser.js +191 -32
- package/dist/tr-bcv-parser.min.js +2 -2
- package/dist/uk-bcv-parser.js +191 -32
- package/dist/uk-bcv-parser.min.js +2 -2
- package/dist/ur-bcv-parser.js +191 -32
- package/dist/ur-bcv-parser.min.js +2 -2
- package/dist/vi-bcv-parser.js +191 -32
- package/dist/vi-bcv-parser.min.js +1 -1
- package/dist/zh-bcv-parser.js +191 -32
- package/dist/zh-bcv-parser.min.js +3 -3
- package/dist/zu-bcv-parser.js +191 -32
- package/dist/zu-bcv-parser.min.js +2 -2
- package/package.json +1 -1
package/dist/ru-bcv-parser.js
CHANGED
|
@@ -548,7 +548,11 @@ class bcv_parser {
|
|
|
548
548
|
const out = [];
|
|
549
549
|
for (var osis of Array.from(this.parsed_entities())) {
|
|
550
550
|
if (osis.osis.length > 0) {
|
|
551
|
-
|
|
551
|
+
const entry = { osis: osis.osis, translations: osis.translations, indices: osis.indices };
|
|
552
|
+
if (osis.osises != null) {
|
|
553
|
+
entry.osises = osis.osises;
|
|
554
|
+
}
|
|
555
|
+
out.push(entry);
|
|
552
556
|
}
|
|
553
557
|
}
|
|
554
558
|
return out;
|
|
@@ -565,6 +569,28 @@ class bcv_parser {
|
|
|
565
569
|
if (entity.passages == null) {
|
|
566
570
|
continue;
|
|
567
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
|
+
}
|
|
568
594
|
if (((entity.type === "b") && (this.options.book_alone_strategy === "ignore")) || ((entity.type === "b_range") && (this.options.book_range_strategy === "ignore")) || (entity.type === "context")) {
|
|
569
595
|
continue;
|
|
570
596
|
}
|
|
@@ -614,34 +640,18 @@ class bcv_parser {
|
|
|
614
640
|
passage.absolute_indices = entity.absolute_indices;
|
|
615
641
|
}
|
|
616
642
|
if ((this.options.consecutive_combination_strategy === 'separate-chapters') && (passage.start.c !== passage.end.c)) {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
c: i,
|
|
630
|
-
v: passage.start.type === 'bcv' ? passageEndVerse : null,
|
|
631
|
-
type: passage.start.type
|
|
632
|
-
};
|
|
633
|
-
nonCombinableOsises.push({
|
|
634
|
-
osis: passage.valid.valid ? this.to_osis(passageStart, passageEnd, translation_alias) : "",
|
|
635
|
-
type: passage.type,
|
|
636
|
-
indices: passage.absolute_indices,
|
|
637
|
-
translations,
|
|
638
|
-
start: passageStart,
|
|
639
|
-
end: passageEnd,
|
|
640
|
-
enclosed_indices: passage.enclosed_absolute_indices,
|
|
641
|
-
entity_id,
|
|
642
|
-
entities: [passage]
|
|
643
|
-
});
|
|
644
|
-
}
|
|
643
|
+
osises.push({
|
|
644
|
+
osis: passage.valid.valid ? this.to_osis(passage.start, passage.end, translation_alias) : "",
|
|
645
|
+
osises: this.get_osises_by_chapter({ osis: "", start: passage.start, end: passage.end }, translation_alias),
|
|
646
|
+
type: passage.type,
|
|
647
|
+
indices: passage.absolute_indices,
|
|
648
|
+
translations,
|
|
649
|
+
start: passage.start,
|
|
650
|
+
end: passage.end,
|
|
651
|
+
enclosed_indices: passage.enclosed_absolute_indices,
|
|
652
|
+
entity_id,
|
|
653
|
+
entities: [passage]
|
|
654
|
+
});
|
|
645
655
|
}
|
|
646
656
|
else {
|
|
647
657
|
osises.push({
|
|
@@ -667,12 +677,54 @@ class bcv_parser {
|
|
|
667
677
|
}
|
|
668
678
|
osises = osises.concat(nonCombinableOsises).sort((osis1, osis2) => osis1.indices[0] - osis2.indices[0]);
|
|
669
679
|
}
|
|
680
|
+
if (this.options.consecutive_combination_strategy === "separate-chapters") {
|
|
681
|
+
for (osis of Array.from(osises)) {
|
|
682
|
+
if (osis.osis.length === 0) {
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
const osises_by_chapter = this.get_osises_by_chapter(osis, translation_alias);
|
|
686
|
+
if (osises_by_chapter.length > 1) {
|
|
687
|
+
osis.osises = osises_by_chapter;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
670
691
|
// Add the osises array to the existing array.
|
|
671
692
|
if (this.options.sequence_combination_strategy === "separate") {
|
|
672
693
|
out = out.concat(osises);
|
|
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;
|
|
@@ -685,7 +737,19 @@ class bcv_parser {
|
|
|
685
737
|
strings.push(osis.osis);
|
|
686
738
|
}
|
|
687
739
|
}
|
|
688
|
-
|
|
740
|
+
let osises_by_chapter = [];
|
|
741
|
+
if (this.options.consecutive_combination_strategy === "separate-chapters") {
|
|
742
|
+
for (osis of Array.from(osises)) {
|
|
743
|
+
if (osis.osises != null) {
|
|
744
|
+
osises_by_chapter = osises_by_chapter.concat(osis.osises);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
const out_entry = { osis: strings.join(","), indices: entity.absolute_indices, translations, entity_id, entities: osises };
|
|
749
|
+
if (osises_by_chapter.length > 0) {
|
|
750
|
+
out_entry.osises = osises_by_chapter;
|
|
751
|
+
}
|
|
752
|
+
out.push(out_entry);
|
|
689
753
|
}
|
|
690
754
|
}
|
|
691
755
|
return out;
|
|
@@ -765,6 +829,96 @@ class bcv_parser {
|
|
|
765
829
|
}
|
|
766
830
|
return out;
|
|
767
831
|
}
|
|
832
|
+
get_osises_by_chapter(passage, translation) {
|
|
833
|
+
if ((passage == null) || (passage.start == null) || (passage.end == null)) {
|
|
834
|
+
return [];
|
|
835
|
+
}
|
|
836
|
+
if ((passage.start.b == null) || (passage.end.b == null) || (passage.start.c == null) || (passage.end.c == null)) {
|
|
837
|
+
return (passage.osis != null) && (passage.osis.length > 0) ? [passage.osis] : [];
|
|
838
|
+
}
|
|
839
|
+
if ((passage.start.b !== passage.end.b) || (passage.start.c === passage.end.c)) {
|
|
840
|
+
return (passage.osis != null) && (passage.osis.length > 0) ? [passage.osis] : [];
|
|
841
|
+
}
|
|
842
|
+
const out = [];
|
|
843
|
+
for (let c = passage.start.c, end = passage.end.c, asc = passage.start.c <= end; asc ? c <= end : c >= end; asc ? c++ : c--) {
|
|
844
|
+
const passageStartVerse = c === passage.start.c ? passage.start.v : 1;
|
|
845
|
+
const passageEndVerse = c === passage.end.c ? passage.end.v : this.translations[translation].chapters[passage.start.b][c - 1];
|
|
846
|
+
const passageStart = {
|
|
847
|
+
b: passage.start.b,
|
|
848
|
+
c,
|
|
849
|
+
v: passage.start.type === "bcv" ? passageStartVerse : null,
|
|
850
|
+
type: passage.start.type
|
|
851
|
+
};
|
|
852
|
+
const passageEnd = {
|
|
853
|
+
b: passage.end.b,
|
|
854
|
+
c,
|
|
855
|
+
v: passage.start.type === "bcv" ? passageEndVerse : null,
|
|
856
|
+
type: passage.start.type
|
|
857
|
+
};
|
|
858
|
+
out.push(this.to_osis(passageStart, passageEnd, translation));
|
|
859
|
+
}
|
|
860
|
+
return out;
|
|
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
|
+
}
|
|
768
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.
|
|
769
923
|
fix_ps151(start, end, translation) {
|
|
770
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`.
|
|
@@ -809,6 +963,11 @@ class bcv_parser {
|
|
|
809
963
|
if (osis.osis.length > 0) {
|
|
810
964
|
var prev_i = out.length - 1;
|
|
811
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
|
+
}
|
|
812
971
|
// Record the start index of the enclosed sequence for use in future iterations.
|
|
813
972
|
if (osis.enclosed_indices[0] !== enclosed_sequence_start) {
|
|
814
973
|
enclosed_sequence_start = osis.enclosed_indices[0];
|
|
@@ -2549,8 +2708,8 @@ bcv_parser.prototype.regexps.pre_book = "[^A-Za-zЀ-ҁ҃-҇Ҋ-ԧⷠ-ⷿꙀ-꙯
|
|
|
2549
2708
|
bcv_parser.prototype.regexps.first = `(?:1-?я|1-?е|1)\\.?${bcv_parser.prototype.regexps.space}*`;
|
|
2550
2709
|
bcv_parser.prototype.regexps.second = `(?:2-?я|2-?е|2)\\.?${bcv_parser.prototype.regexps.space}*`;
|
|
2551
2710
|
bcv_parser.prototype.regexps.third = `(?:3-?я|3-?е|3)\\.?${bcv_parser.prototype.regexps.space}*`;
|
|
2552
|
-
bcv_parser.prototype.regexps.range_and =
|
|
2553
|
-
bcv_parser.prototype.regexps.range_only =
|
|
2711
|
+
bcv_parser.prototype.regexps.range_and = `(?:[&\\u2013\\u2014-]|и|—)`;
|
|
2712
|
+
bcv_parser.prototype.regexps.range_only = `(?:[\\u2013\\u2014-]|—)`;
|
|
2554
2713
|
// Each book regexp should return two parenthesized objects: an optional preliminary character and the book itself.
|
|
2555
2714
|
bcv_parser.prototype.regexps.get_books = function (include_apocrypha, case_sensitive) {
|
|
2556
2715
|
const books = [
|