usfm-grammar-web 3.2.0 → 3.2.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/README.md +147 -9
- package/dist/bundle.mjs +756 -216
- package/dist/bundle.mjs.map +1 -1
- package/package.json +1 -1
- package/tree-sitter-usfm.wasm +0 -0
package/dist/bundle.mjs
CHANGED
|
@@ -3468,6 +3468,175 @@ module.exports = new URL("tree-sitter.0080292a.wasm", import.meta.url).toString(
|
|
|
3468
3468
|
|
|
3469
3469
|
|
|
3470
3470
|
var $dc2P8 = parcelRequire("dc2P8");
|
|
3471
|
+
const $28b0061e56e1edf2$export$3ea3efefd6f5792b = [
|
|
3472
|
+
'ide',
|
|
3473
|
+
'usfm',
|
|
3474
|
+
'h',
|
|
3475
|
+
'toc',
|
|
3476
|
+
'toca',
|
|
3477
|
+
'imt',
|
|
3478
|
+
'is',
|
|
3479
|
+
'ip',
|
|
3480
|
+
'ipi',
|
|
3481
|
+
'im',
|
|
3482
|
+
'imi',
|
|
3483
|
+
'ipq',
|
|
3484
|
+
'imq',
|
|
3485
|
+
'ipr',
|
|
3486
|
+
'ipc',
|
|
3487
|
+
'iq',
|
|
3488
|
+
'ib',
|
|
3489
|
+
'ili',
|
|
3490
|
+
'iot',
|
|
3491
|
+
'io',
|
|
3492
|
+
'iex',
|
|
3493
|
+
'imte',
|
|
3494
|
+
'ie',
|
|
3495
|
+
'mt',
|
|
3496
|
+
'mte',
|
|
3497
|
+
'cl',
|
|
3498
|
+
'cd',
|
|
3499
|
+
'ms',
|
|
3500
|
+
'mr',
|
|
3501
|
+
's',
|
|
3502
|
+
'sr',
|
|
3503
|
+
'r',
|
|
3504
|
+
'd',
|
|
3505
|
+
'sp',
|
|
3506
|
+
'sd',
|
|
3507
|
+
'q',
|
|
3508
|
+
'qr',
|
|
3509
|
+
'qc',
|
|
3510
|
+
'qa',
|
|
3511
|
+
'qm',
|
|
3512
|
+
'qd',
|
|
3513
|
+
'lh',
|
|
3514
|
+
'li',
|
|
3515
|
+
'lf',
|
|
3516
|
+
'lim',
|
|
3517
|
+
'sts',
|
|
3518
|
+
'rem',
|
|
3519
|
+
'lit',
|
|
3520
|
+
'restore'
|
|
3521
|
+
];
|
|
3522
|
+
const $28b0061e56e1edf2$export$bfe3d604e5046dbb = [
|
|
3523
|
+
'f',
|
|
3524
|
+
'fe',
|
|
3525
|
+
'ef',
|
|
3526
|
+
'efe',
|
|
3527
|
+
'x',
|
|
3528
|
+
'ex'
|
|
3529
|
+
];
|
|
3530
|
+
const $28b0061e56e1edf2$export$32d1909bfb943eb0 = [
|
|
3531
|
+
'add',
|
|
3532
|
+
'bk',
|
|
3533
|
+
'dc',
|
|
3534
|
+
'ior',
|
|
3535
|
+
'iqt',
|
|
3536
|
+
'k',
|
|
3537
|
+
'litl',
|
|
3538
|
+
'nd',
|
|
3539
|
+
'ord',
|
|
3540
|
+
'pn',
|
|
3541
|
+
'png',
|
|
3542
|
+
'qac',
|
|
3543
|
+
'qs',
|
|
3544
|
+
'qt',
|
|
3545
|
+
'rq',
|
|
3546
|
+
'sig',
|
|
3547
|
+
'sls',
|
|
3548
|
+
'tl',
|
|
3549
|
+
'ta',
|
|
3550
|
+
'wj',
|
|
3551
|
+
'em',
|
|
3552
|
+
'bd',
|
|
3553
|
+
'bdit',
|
|
3554
|
+
'it',
|
|
3555
|
+
'no',
|
|
3556
|
+
'sc',
|
|
3557
|
+
'sup',
|
|
3558
|
+
'rb',
|
|
3559
|
+
'pro',
|
|
3560
|
+
'w',
|
|
3561
|
+
'wh',
|
|
3562
|
+
'wa',
|
|
3563
|
+
'wl',
|
|
3564
|
+
'wg',
|
|
3565
|
+
'lik',
|
|
3566
|
+
'liv',
|
|
3567
|
+
'jmp',
|
|
3568
|
+
'fr',
|
|
3569
|
+
'ft',
|
|
3570
|
+
'fk',
|
|
3571
|
+
'fq',
|
|
3572
|
+
'fqa',
|
|
3573
|
+
'fl',
|
|
3574
|
+
'fw',
|
|
3575
|
+
'fp',
|
|
3576
|
+
'fv',
|
|
3577
|
+
'fdc',
|
|
3578
|
+
'xo',
|
|
3579
|
+
'xop',
|
|
3580
|
+
'xt',
|
|
3581
|
+
'xta',
|
|
3582
|
+
'xk',
|
|
3583
|
+
'xq',
|
|
3584
|
+
'xot',
|
|
3585
|
+
'xnt',
|
|
3586
|
+
'xdc'
|
|
3587
|
+
];
|
|
3588
|
+
const $28b0061e56e1edf2$export$ec3044778745fabd = $28b0061e56e1edf2$export$32d1909bfb943eb0.map((item)=>`${item}Nested`);
|
|
3589
|
+
const $28b0061e56e1edf2$export$38bc6f52843beb2a = {
|
|
3590
|
+
w: 'lemma',
|
|
3591
|
+
rb: 'gloss',
|
|
3592
|
+
xt: 'href',
|
|
3593
|
+
fig: 'alt',
|
|
3594
|
+
xt_standalone: 'href',
|
|
3595
|
+
xtNested: 'href',
|
|
3596
|
+
ref: 'loc',
|
|
3597
|
+
milestone: 'who',
|
|
3598
|
+
k: 'key',
|
|
3599
|
+
wl: 'lang',
|
|
3600
|
+
tl: 'lang',
|
|
3601
|
+
vid: 'ref'
|
|
3602
|
+
};
|
|
3603
|
+
const $28b0061e56e1edf2$export$af42bd8f70df8555 = [
|
|
3604
|
+
'tc',
|
|
3605
|
+
'th',
|
|
3606
|
+
'tcr',
|
|
3607
|
+
'thr',
|
|
3608
|
+
'tcc',
|
|
3609
|
+
'thc'
|
|
3610
|
+
];
|
|
3611
|
+
const $28b0061e56e1edf2$export$c4d2f24f22330b2a = [
|
|
3612
|
+
'fig',
|
|
3613
|
+
'cat',
|
|
3614
|
+
'esb',
|
|
3615
|
+
'b',
|
|
3616
|
+
'ph',
|
|
3617
|
+
'pi'
|
|
3618
|
+
];
|
|
3619
|
+
const $28b0061e56e1edf2$export$d19275a111c0e9e6 = {
|
|
3620
|
+
TABLE_CELL_MARKERS: new Set($28b0061e56e1edf2$export$af42bd8f70df8555),
|
|
3621
|
+
CHAR_STYLE_MARKERS: new Set($28b0061e56e1edf2$export$32d1909bfb943eb0),
|
|
3622
|
+
NESTED_CHAR_STYLE_MARKERS: new Set($28b0061e56e1edf2$export$ec3044778745fabd),
|
|
3623
|
+
OTHER_PARA_NESTABLES: new Set([
|
|
3624
|
+
'text',
|
|
3625
|
+
'footnote',
|
|
3626
|
+
'crossref',
|
|
3627
|
+
'verseText',
|
|
3628
|
+
'v',
|
|
3629
|
+
'b',
|
|
3630
|
+
'milestone',
|
|
3631
|
+
'zNameSpace'
|
|
3632
|
+
]),
|
|
3633
|
+
NOTE_MARKERS: new Set($28b0061e56e1edf2$export$bfe3d604e5046dbb),
|
|
3634
|
+
PARA_STYLE_MARKERS: new Set($28b0061e56e1edf2$export$3ea3efefd6f5792b)
|
|
3635
|
+
};
|
|
3636
|
+
const $28b0061e56e1edf2$export$8e480ab8367e6dbc = /(\w+) (\d+):([\d\w]+(?:-[\d\w]+)?)/;
|
|
3637
|
+
const $28b0061e56e1edf2$export$7dc487a0fa1a604f = '3.1.2';
|
|
3638
|
+
|
|
3639
|
+
|
|
3471
3640
|
const $142605215cbb4f88$export$b32929182cc4fefe = [
|
|
3472
3641
|
'USJ',
|
|
3473
3642
|
'table'
|
|
@@ -3484,25 +3653,35 @@ const $142605215cbb4f88$export$aa24f570494ce8d0 = [
|
|
|
3484
3653
|
'content',
|
|
3485
3654
|
'number',
|
|
3486
3655
|
'sid',
|
|
3656
|
+
'eid',
|
|
3657
|
+
'closed',
|
|
3658
|
+
'status',
|
|
3487
3659
|
'code',
|
|
3488
3660
|
'caller',
|
|
3489
3661
|
'align',
|
|
3490
3662
|
'version',
|
|
3491
3663
|
'altnumber',
|
|
3492
3664
|
'pubnumber',
|
|
3493
|
-
'category'
|
|
3665
|
+
'category',
|
|
3666
|
+
'vid',
|
|
3667
|
+
'h'
|
|
3494
3668
|
];
|
|
3495
3669
|
const $142605215cbb4f88$export$1790a88fa433c8d6 = [
|
|
3496
|
-
'style',
|
|
3497
3670
|
'number',
|
|
3498
|
-
'sid',
|
|
3499
3671
|
'code',
|
|
3500
3672
|
'caller',
|
|
3501
3673
|
'align',
|
|
3674
|
+
'sid',
|
|
3675
|
+
'eid',
|
|
3676
|
+
'style',
|
|
3677
|
+
'closed',
|
|
3678
|
+
'status',
|
|
3502
3679
|
'version',
|
|
3503
3680
|
'altnumber',
|
|
3504
3681
|
'pubnumber',
|
|
3505
|
-
'category'
|
|
3682
|
+
'category',
|
|
3683
|
+
'vid',
|
|
3684
|
+
'h'
|
|
3506
3685
|
];
|
|
3507
3686
|
const $142605215cbb4f88$export$c63c0b6e358f0774 = [
|
|
3508
3687
|
'char',
|
|
@@ -3521,6 +3700,9 @@ const $142605215cbb4f88$export$1187115108c84d45 = [
|
|
|
3521
3700
|
class $ce44dcc4919407eb$var$USFMGenerator {
|
|
3522
3701
|
constructor(){
|
|
3523
3702
|
this.usfmString = '';
|
|
3703
|
+
this.currentBook = null;
|
|
3704
|
+
this.currentChapter = null;
|
|
3705
|
+
this.currentVerse = null;
|
|
3524
3706
|
}
|
|
3525
3707
|
usjToUsfm(usjObj, nested = false) {
|
|
3526
3708
|
if (usjObj.type === 'optbreak') {
|
|
@@ -3533,11 +3715,28 @@ class $ce44dcc4919407eb$var$USFMGenerator {
|
|
|
3533
3715
|
this.usfmString += '// ';
|
|
3534
3716
|
return;
|
|
3535
3717
|
}
|
|
3536
|
-
|
|
3718
|
+
let marker = null;
|
|
3719
|
+
if (usjObj.marker) marker = usjObj.marker;
|
|
3720
|
+
else if (usjObj.type === 'ref') marker = 'ref';
|
|
3721
|
+
else if (usjObj.type === 'list') marker = 'list-s\\*\n';
|
|
3722
|
+
else marker = usjObj.type;
|
|
3723
|
+
if (usjObj.code) this.currentBook = usjObj.code;
|
|
3724
|
+
else if (marker === 'c') {
|
|
3725
|
+
this.currentChapter = usjObj.number;
|
|
3726
|
+
this.currentVerse = null; // Reset currentVerse when a new chapter starts for vid
|
|
3727
|
+
} else if (marker === 'v') this.currentVerse = usjObj.number;
|
|
3728
|
+
if (usjObj.vid) {
|
|
3729
|
+
const currentRef = `${this.currentBook} ${this.currentChapter}:${this.currentVerse}`;
|
|
3730
|
+
if (currentRef !== usjObj.vid) {
|
|
3731
|
+
this.usfmString += `\\vid|ref=\"${usjObj.vid}\" `;
|
|
3732
|
+
if (usjObj.h) this.usfmString += `h="${usjObj.h}" `;
|
|
3733
|
+
this.usfmString += '\\*\n';
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3537
3736
|
if (!(0, $142605215cbb4f88$export$b32929182cc4fefe).includes(usjObj.type)) {
|
|
3538
3737
|
this.usfmString += '\\';
|
|
3539
3738
|
if (nested && usjObj.type === 'char') this.usfmString += '+';
|
|
3540
|
-
this.usfmString += `${
|
|
3739
|
+
this.usfmString += `${marker} `;
|
|
3541
3740
|
}
|
|
3542
3741
|
[
|
|
3543
3742
|
'code',
|
|
@@ -3548,12 +3747,12 @@ class $ce44dcc4919407eb$var$USFMGenerator {
|
|
|
3548
3747
|
});
|
|
3549
3748
|
if (usjObj.category) this.usfmString += `\\cat ${usjObj.category}\\cat*\n`;
|
|
3550
3749
|
if (usjObj.altnumber) {
|
|
3551
|
-
if (
|
|
3552
|
-
else if (
|
|
3750
|
+
if (marker === 'c') this.usfmString += `\\ca ${usjObj.altnumber} \\ca*\n`;
|
|
3751
|
+
else if (marker === 'v') this.usfmString += `\\va ${usjObj.altnumber} \\va* `;
|
|
3553
3752
|
}
|
|
3554
3753
|
if (usjObj.pubnumber) {
|
|
3555
|
-
if (
|
|
3556
|
-
else if (
|
|
3754
|
+
if (marker === 'c') this.usfmString += `\\cp ${usjObj.pubnumber}\n`;
|
|
3755
|
+
else if (marker === 'v') this.usfmString += `\\vp ${usjObj.pubnumber} \\vp* `;
|
|
3557
3756
|
}
|
|
3558
3757
|
if (Array.isArray(usjObj.content)) usjObj.content.forEach((item)=>{
|
|
3559
3758
|
if (typeof item === 'string') this.usfmString += item;
|
|
@@ -3571,7 +3770,7 @@ class $ce44dcc4919407eb$var$USFMGenerator {
|
|
|
3571
3770
|
if ((0, $142605215cbb4f88$export$75b2f422ff60acaf).includes(usjObj.type)) {
|
|
3572
3771
|
this.usfmString += '\\';
|
|
3573
3772
|
if (nested && usjObj.type === 'char') this.usfmString += '+';
|
|
3574
|
-
this.usfmString += `${
|
|
3773
|
+
this.usfmString += `${marker}* `;
|
|
3575
3774
|
}
|
|
3576
3775
|
if (usjObj.type === 'ms') {
|
|
3577
3776
|
if ('sid' in usjObj) {
|
|
@@ -3581,7 +3780,9 @@ class $ce44dcc4919407eb$var$USFMGenerator {
|
|
|
3581
3780
|
this.usfmString = `${this.usfmString.trim()}\\*`;
|
|
3582
3781
|
}
|
|
3583
3782
|
if (usjObj.type === 'sidebar') this.usfmString += '\\esbe';
|
|
3783
|
+
else if (usjObj.type === 'list') this.usfmString += '\\list-e\\*';
|
|
3584
3784
|
if (!(0, $142605215cbb4f88$export$c63c0b6e358f0774).includes(usjObj.type) && this.usfmString[this.usfmString.length - 1] !== '\n') this.usfmString += '\n';
|
|
3785
|
+
if (marker === 'id') this.usfmString += `\\usfm ${0, $28b0061e56e1edf2$export$7dc487a0fa1a604f}\n`;
|
|
3585
3786
|
return this.usfmString;
|
|
3586
3787
|
}
|
|
3587
3788
|
usxToUsfm(xmlObj, nested = false) {
|
|
@@ -3597,6 +3798,19 @@ class $ce44dcc4919407eb$var$USFMGenerator {
|
|
|
3597
3798
|
'verse',
|
|
3598
3799
|
'chapter'
|
|
3599
3800
|
].includes(objType) && xmlObj.hasAttribute('eid')) return;
|
|
3801
|
+
if (xmlObj.hasAttribute('code')) this.currentBook = xmlObj.getAttribute('code');
|
|
3802
|
+
else if (xmlObj.getAttribute('style') === 'c') {
|
|
3803
|
+
this.currentChapter = xmlObj.getAttribute('number');
|
|
3804
|
+
this.currentVerse = null; // Reset currentVerse when a new chapter starts for vid
|
|
3805
|
+
} else if (xmlObj.getAttribute('style') === 'v') this.currentVerse = xmlObj.getAttribute('number');
|
|
3806
|
+
if (xmlObj.hasAttribute('vid')) {
|
|
3807
|
+
const currentReference = `${this.currentBook} ${this.currentChapter}:${this.currentVerse}`;
|
|
3808
|
+
if (currentReference !== xmlObj.getAttribute('vid')) {
|
|
3809
|
+
this.usfmString += `\n\\vid|ref="${xmlObj.getAttribute('vid')}" `;
|
|
3810
|
+
if (xmlObj.hasAttribute('h')) this.usfmString += `h="${xmlObj.getAttribute('h')}" `;
|
|
3811
|
+
this.usfmString += '\\*\n';
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3600
3814
|
if (!(0, $142605215cbb4f88$export$1187115108c84d45).includes(objType)) this.usfmString += '\n';
|
|
3601
3815
|
if (objType === 'optbreak') {
|
|
3602
3816
|
if (this.usfmString !== '' && ![
|
|
@@ -3606,8 +3820,8 @@ class $ce44dcc4919407eb$var$USFMGenerator {
|
|
|
3606
3820
|
'\t'
|
|
3607
3821
|
].includes(this.usfmString.slice(-1))) this.usfmString += ' ';
|
|
3608
3822
|
this.usfmString += '// ';
|
|
3609
|
-
}
|
|
3610
|
-
if (xmlObj.hasAttribute('style')) {
|
|
3823
|
+
} else if (objType === 'list') this.usfmString += '\\list-s\\*\n';
|
|
3824
|
+
else if (xmlObj.hasAttribute('style')) {
|
|
3611
3825
|
marker = xmlObj.getAttribute('style');
|
|
3612
3826
|
if (nested && objType === 'char' && ![
|
|
3613
3827
|
'xt',
|
|
@@ -3667,6 +3881,11 @@ class $ce44dcc4919407eb$var$USFMGenerator {
|
|
|
3667
3881
|
else this.usfmString += `\\${marker}*`;
|
|
3668
3882
|
}
|
|
3669
3883
|
if (objType === 'sidebar') this.usfmString += '\n\\esbe\n';
|
|
3884
|
+
else if (objType === 'list') this.usfmString += '\n\\list-e\\*\n';
|
|
3885
|
+
if (marker === 'id') {
|
|
3886
|
+
if (!this.usfmString.endsWith('\n')) this.usfmString += '\n';
|
|
3887
|
+
this.usfmString += `\\usfm ${0, $28b0061e56e1edf2$export$7dc487a0fa1a604f}\n`;
|
|
3888
|
+
}
|
|
3670
3889
|
}
|
|
3671
3890
|
bibleNlptoUsfm(bibleNlpObj) {
|
|
3672
3891
|
const vrefPattern = /([a-zA-Z0-9]{3}) (\d+):(.*)/;
|
|
@@ -3693,7 +3912,8 @@ class $ce44dcc4919407eb$var$USFMGenerator {
|
|
|
3693
3912
|
currChapter = chap;
|
|
3694
3913
|
}
|
|
3695
3914
|
if (!this.usfmString.endsWith('\n')) this.usfmString += ' ';
|
|
3696
|
-
this.usfmString += `\\v ${verse} ${verseText}`;
|
|
3915
|
+
if (verse.trim() !== '') this.usfmString += `\\v ${verse} ${verseText}`;
|
|
3916
|
+
else this.usfmString += ` ${verseText}`;
|
|
3697
3917
|
}
|
|
3698
3918
|
}
|
|
3699
3919
|
}
|
|
@@ -3701,166 +3921,6 @@ var $ce44dcc4919407eb$export$2e2bcd8739ae039 = $ce44dcc4919407eb$var$USFMGenerat
|
|
|
3701
3921
|
|
|
3702
3922
|
|
|
3703
3923
|
//Logics for syntax-tree to dict(USJ) conversions
|
|
3704
|
-
const $28b0061e56e1edf2$export$3ea3efefd6f5792b = [
|
|
3705
|
-
'ide',
|
|
3706
|
-
'usfm',
|
|
3707
|
-
'h',
|
|
3708
|
-
'toc',
|
|
3709
|
-
'toca',
|
|
3710
|
-
'imt',
|
|
3711
|
-
'is',
|
|
3712
|
-
'ip',
|
|
3713
|
-
'ipi',
|
|
3714
|
-
'im',
|
|
3715
|
-
'imi',
|
|
3716
|
-
'ipq',
|
|
3717
|
-
'imq',
|
|
3718
|
-
'ipr',
|
|
3719
|
-
'iq',
|
|
3720
|
-
'ib',
|
|
3721
|
-
'ili',
|
|
3722
|
-
'iot',
|
|
3723
|
-
'io',
|
|
3724
|
-
'iex',
|
|
3725
|
-
'imte',
|
|
3726
|
-
'ie',
|
|
3727
|
-
'mt',
|
|
3728
|
-
'mte',
|
|
3729
|
-
'cl',
|
|
3730
|
-
'cd',
|
|
3731
|
-
'ms',
|
|
3732
|
-
'mr',
|
|
3733
|
-
's',
|
|
3734
|
-
'sr',
|
|
3735
|
-
'r',
|
|
3736
|
-
'd',
|
|
3737
|
-
'sp',
|
|
3738
|
-
'sd',
|
|
3739
|
-
'q',
|
|
3740
|
-
'qr',
|
|
3741
|
-
'qc',
|
|
3742
|
-
'qa',
|
|
3743
|
-
'qm',
|
|
3744
|
-
'qd',
|
|
3745
|
-
'lh',
|
|
3746
|
-
'li',
|
|
3747
|
-
'lf',
|
|
3748
|
-
'lim',
|
|
3749
|
-
'sts',
|
|
3750
|
-
'rem',
|
|
3751
|
-
'lit',
|
|
3752
|
-
'restore'
|
|
3753
|
-
];
|
|
3754
|
-
const $28b0061e56e1edf2$export$bfe3d604e5046dbb = [
|
|
3755
|
-
'f',
|
|
3756
|
-
'fe',
|
|
3757
|
-
'ef',
|
|
3758
|
-
'efe',
|
|
3759
|
-
'x',
|
|
3760
|
-
'ex'
|
|
3761
|
-
];
|
|
3762
|
-
const $28b0061e56e1edf2$export$32d1909bfb943eb0 = [
|
|
3763
|
-
'add',
|
|
3764
|
-
'bk',
|
|
3765
|
-
'dc',
|
|
3766
|
-
'ior',
|
|
3767
|
-
'iqt',
|
|
3768
|
-
'k',
|
|
3769
|
-
'litl',
|
|
3770
|
-
'nd',
|
|
3771
|
-
'ord',
|
|
3772
|
-
'pn',
|
|
3773
|
-
'png',
|
|
3774
|
-
'qac',
|
|
3775
|
-
'qs',
|
|
3776
|
-
'qt',
|
|
3777
|
-
'rq',
|
|
3778
|
-
'sig',
|
|
3779
|
-
'sls',
|
|
3780
|
-
'tl',
|
|
3781
|
-
'wj',
|
|
3782
|
-
'em',
|
|
3783
|
-
'bd',
|
|
3784
|
-
'bdit',
|
|
3785
|
-
'it',
|
|
3786
|
-
'no',
|
|
3787
|
-
'sc',
|
|
3788
|
-
'sup',
|
|
3789
|
-
'rb',
|
|
3790
|
-
'pro',
|
|
3791
|
-
'w',
|
|
3792
|
-
'wh',
|
|
3793
|
-
'wa',
|
|
3794
|
-
'wg',
|
|
3795
|
-
'lik',
|
|
3796
|
-
'liv',
|
|
3797
|
-
'jmp',
|
|
3798
|
-
'fr',
|
|
3799
|
-
'ft',
|
|
3800
|
-
'fk',
|
|
3801
|
-
'fq',
|
|
3802
|
-
'fqa',
|
|
3803
|
-
'fl',
|
|
3804
|
-
'fw',
|
|
3805
|
-
'fp',
|
|
3806
|
-
'fv',
|
|
3807
|
-
'fdc',
|
|
3808
|
-
'xo',
|
|
3809
|
-
'xop',
|
|
3810
|
-
'xt',
|
|
3811
|
-
'xta',
|
|
3812
|
-
'xk',
|
|
3813
|
-
'xq',
|
|
3814
|
-
'xot',
|
|
3815
|
-
'xnt',
|
|
3816
|
-
'xdc'
|
|
3817
|
-
];
|
|
3818
|
-
const $28b0061e56e1edf2$export$ec3044778745fabd = $28b0061e56e1edf2$export$32d1909bfb943eb0.map((item)=>`${item}Nested`);
|
|
3819
|
-
const $28b0061e56e1edf2$export$38bc6f52843beb2a = {
|
|
3820
|
-
w: 'lemma',
|
|
3821
|
-
rb: 'gloss',
|
|
3822
|
-
xt: 'href',
|
|
3823
|
-
fig: 'alt',
|
|
3824
|
-
xt_standalone: 'href',
|
|
3825
|
-
xtNested: 'href',
|
|
3826
|
-
ref: 'loc',
|
|
3827
|
-
milestone: 'who',
|
|
3828
|
-
k: 'key'
|
|
3829
|
-
};
|
|
3830
|
-
const $28b0061e56e1edf2$export$af42bd8f70df8555 = [
|
|
3831
|
-
'tc',
|
|
3832
|
-
'th',
|
|
3833
|
-
'tcr',
|
|
3834
|
-
'thr',
|
|
3835
|
-
'tcc',
|
|
3836
|
-
'thc'
|
|
3837
|
-
];
|
|
3838
|
-
const $28b0061e56e1edf2$export$c4d2f24f22330b2a = [
|
|
3839
|
-
'fig',
|
|
3840
|
-
'cat',
|
|
3841
|
-
'esb',
|
|
3842
|
-
'b',
|
|
3843
|
-
'ph',
|
|
3844
|
-
'pi'
|
|
3845
|
-
];
|
|
3846
|
-
const $28b0061e56e1edf2$export$d19275a111c0e9e6 = {
|
|
3847
|
-
TABLE_CELL_MARKERS: new Set($28b0061e56e1edf2$export$af42bd8f70df8555),
|
|
3848
|
-
CHAR_STYLE_MARKERS: new Set($28b0061e56e1edf2$export$32d1909bfb943eb0),
|
|
3849
|
-
NESTED_CHAR_STYLE_MARKERS: new Set($28b0061e56e1edf2$export$ec3044778745fabd),
|
|
3850
|
-
OTHER_PARA_NESTABLES: new Set([
|
|
3851
|
-
'text',
|
|
3852
|
-
'footnote',
|
|
3853
|
-
'crossref',
|
|
3854
|
-
'verseText',
|
|
3855
|
-
'v',
|
|
3856
|
-
'b',
|
|
3857
|
-
'milestone',
|
|
3858
|
-
'zNameSpace'
|
|
3859
|
-
]),
|
|
3860
|
-
NOTE_MARKERS: new Set($28b0061e56e1edf2$export$bfe3d604e5046dbb),
|
|
3861
|
-
PARA_STYLE_MARKERS: new Set($28b0061e56e1edf2$export$3ea3efefd6f5792b)
|
|
3862
|
-
};
|
|
3863
|
-
|
|
3864
3924
|
|
|
3865
3925
|
|
|
3866
3926
|
var $dc2P8 = parcelRequire("dc2P8");
|
|
@@ -3889,7 +3949,6 @@ function $6dfa97aa668afc29$export$2d0a2b758e44ba4e(lang) {
|
|
|
3889
3949
|
(milestoneTag)
|
|
3890
3950
|
(milestoneStartTag)
|
|
3891
3951
|
(milestoneEndTag)
|
|
3892
|
-
(zSpaceTag)
|
|
3893
3952
|
] @ms-name)`);
|
|
3894
3953
|
}
|
|
3895
3954
|
function $6dfa97aa668afc29$export$8ae82a3cc175562e(lang) {
|
|
@@ -3930,9 +3989,11 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
3930
3989
|
constructor(treeSitterLanguageObj, usfmString, usjRootObj = null){
|
|
3931
3990
|
this.usfmLanguage = treeSitterLanguageObj;
|
|
3932
3991
|
this.usfm = usfmString;
|
|
3992
|
+
this.warnings = []; // Initialize warnings array to store any warnings during processing
|
|
3993
|
+
this.errors = [];
|
|
3933
3994
|
this.jsonRootObj = usjRootObj || {
|
|
3934
3995
|
type: 'USJ',
|
|
3935
|
-
version:
|
|
3996
|
+
version: (0, $28b0061e56e1edf2$export$7dc487a0fa1a604f),
|
|
3936
3997
|
content: []
|
|
3937
3998
|
};
|
|
3938
3999
|
// Cache for the query objects
|
|
@@ -3947,7 +4008,10 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
3947
4008
|
this.markerSets = (0, $28b0061e56e1edf2$export$d19275a111c0e9e6);
|
|
3948
4009
|
this.parseState = {
|
|
3949
4010
|
bookSlug: null,
|
|
3950
|
-
currentChapter: null
|
|
4011
|
+
currentChapter: null,
|
|
4012
|
+
prevVerseSid: null,
|
|
4013
|
+
vidH: null,
|
|
4014
|
+
vidRef: null
|
|
3951
4015
|
};
|
|
3952
4016
|
// maps and id to a fn;
|
|
3953
4017
|
this.dispatchMap = this.populateDispatchMap();
|
|
@@ -3985,6 +4049,7 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
3985
4049
|
sid: chapRef
|
|
3986
4050
|
};
|
|
3987
4051
|
this.parseState.currentChapter = chapNum;
|
|
4052
|
+
this.parseState.prevVerseSid = null; // Reset prevVerseSid when a new chapter starts
|
|
3988
4053
|
chapCap.forEach((cap)=>{
|
|
3989
4054
|
if (cap.name === 'alt-num') chapJsonObj.altnumber = this.usfm.substring(cap.node.startIndex, cap.node.endIndex).trim();
|
|
3990
4055
|
if (cap.name === 'pub-num') chapJsonObj.pubnumber = this.usfm.substring(cap.node.startIndex, cap.node.endIndex).trim();
|
|
@@ -4025,6 +4090,7 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4025
4090
|
});
|
|
4026
4091
|
const ref = `${this.parseState.bookSlug} ${this.parseState.currentChapter}:${verseNum}`;
|
|
4027
4092
|
vJsonObj.sid = ref.trim();
|
|
4093
|
+
this.parseState.prevVerseSid = vJsonObj.sid; // Update prevVerseSid for vid attribute handling
|
|
4028
4094
|
parentJsonObj.content.push(vJsonObj);
|
|
4029
4095
|
}
|
|
4030
4096
|
nodeToUSJCaVa(node, parentJsonObj) {
|
|
@@ -4040,6 +4106,46 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4040
4106
|
charJsonObj.altnumber = altNum;
|
|
4041
4107
|
parentJsonObj.content.push(charJsonObj);
|
|
4042
4108
|
}
|
|
4109
|
+
node2UsxVid(node, _parentJsonObj) {
|
|
4110
|
+
// Build elements for vid and h attributes
|
|
4111
|
+
this.parseState.vidH = null;
|
|
4112
|
+
this.parseState.vidRef = null;
|
|
4113
|
+
for (const child of node.children){
|
|
4114
|
+
let attribValue = null;
|
|
4115
|
+
for (const innerChild of child.children)if (innerChild.type === 'attributeValue') {
|
|
4116
|
+
attribValue = this.usfm.slice(innerChild.startIndex, innerChild.endIndex).trim();
|
|
4117
|
+
break;
|
|
4118
|
+
}
|
|
4119
|
+
if (child.type === 'hAttribute') this.parseState.vidH = attribValue;
|
|
4120
|
+
else if (child.type === 'refAttribute') this.parseState.vidRef = attribValue;
|
|
4121
|
+
else if (child.type === 'defaultAttribute') this.parseState.vidRef = attribValue;
|
|
4122
|
+
}
|
|
4123
|
+
if (this.parseState.vidRef) {
|
|
4124
|
+
const refMatch = this.parseState.vidRef.match((0, $28b0061e56e1edf2$export$8e480ab8367e6dbc));
|
|
4125
|
+
if (refMatch) {
|
|
4126
|
+
this.parseState.bookSlug = refMatch[1];
|
|
4127
|
+
this.parseState.currentChapter = refMatch[2];
|
|
4128
|
+
} else {
|
|
4129
|
+
this.warnings.push(`vid-ref attribute value does not match expected pattern: ${this.parseState.vidRef}`);
|
|
4130
|
+
this.parseState.vidRef = null; // Reset vidRef if it doesn't match the expected pattern
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4134
|
+
addVidAttributesToNode(parentJsonObj) {
|
|
4135
|
+
//Add vid attributes to the given xml node if they exist in parse state
|
|
4136
|
+
if (this.parseState.vidH) {
|
|
4137
|
+
parentJsonObj.h = this.parseState.vidH;
|
|
4138
|
+
this.parseState.vidH = null; // Reset after use
|
|
4139
|
+
}
|
|
4140
|
+
if (this.parseState.vidRef) {
|
|
4141
|
+
parentJsonObj.vid = this.parseState.vidRef;
|
|
4142
|
+
this.parseState.vidRef = null; // Reset after use
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
addVidAttributeSecondAttempt(parentJsonObj, firstChild) {
|
|
4146
|
+
// Add vid attributes to the given json node if firstChild is not a verse tag
|
|
4147
|
+
if (!parentJsonObj.vid && this.parseState.prevVerseSid && firstChild && firstChild.type !== 'v') parentJsonObj.vid = this.parseState.prevVerseSid;
|
|
4148
|
+
}
|
|
4043
4149
|
nodeToUSJPara(node, parentJsonObj) {
|
|
4044
4150
|
// Build paragraph nodes in USJ
|
|
4045
4151
|
if (node.children[0].type.endsWith('Block')) node.children[0].children.forEach((child)=>{
|
|
@@ -4049,16 +4155,20 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4049
4155
|
const paraTagCap = this.getQuery('para').captures(node)[0];
|
|
4050
4156
|
// const paraTagCap = this.queries.para.captures(node)[0];
|
|
4051
4157
|
const paraMarker = paraTagCap.node.type;
|
|
4052
|
-
if (paraMarker === 'b')
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4158
|
+
if (paraMarker === 'b') {
|
|
4159
|
+
parentJsonObj.content.push({
|
|
4160
|
+
type: 'para',
|
|
4161
|
+
marker: paraMarker
|
|
4162
|
+
});
|
|
4163
|
+
this.addVidAttributesToNode(parentJsonObj.content[parentJsonObj.content.length - 1]);
|
|
4164
|
+
} else if (!paraMarker.endsWith('Block')) {
|
|
4057
4165
|
const paraJsonObj = {
|
|
4058
4166
|
type: 'para',
|
|
4059
4167
|
marker: paraMarker,
|
|
4060
4168
|
content: []
|
|
4061
4169
|
};
|
|
4170
|
+
this.addVidAttributesToNode(paraJsonObj);
|
|
4171
|
+
this.addVidAttributeSecondAttempt(paraJsonObj, paraTagCap.node.children[1]);
|
|
4062
4172
|
paraTagCap.node.children.forEach((child)=>{
|
|
4063
4173
|
this.nodeToUSJ(child, paraJsonObj);
|
|
4064
4174
|
});
|
|
@@ -4074,6 +4184,8 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4074
4184
|
marker: paraMarker,
|
|
4075
4185
|
content: []
|
|
4076
4186
|
};
|
|
4187
|
+
this.addVidAttributesToNode(paraJsonObj);
|
|
4188
|
+
this.addVidAttributeSecondAttempt(paraJsonObj, node.children[1]);
|
|
4077
4189
|
node.children.slice(1).forEach((child)=>{
|
|
4078
4190
|
this.nodeToUSJ(child, paraJsonObj);
|
|
4079
4191
|
});
|
|
@@ -4091,6 +4203,7 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4091
4203
|
content: []
|
|
4092
4204
|
};
|
|
4093
4205
|
noteJsonObj.caller = this.usfm.substring(callerNode.startIndex, callerNode.endIndex).trim();
|
|
4206
|
+
this.addVidAttributesToNode(noteJsonObj);
|
|
4094
4207
|
for(let i = 2; i < node.children.length - 1; i++)this.nodeToUSJ(node.children[i], noteJsonObj);
|
|
4095
4208
|
parentJsonObj.content.push(noteJsonObj);
|
|
4096
4209
|
}
|
|
@@ -4127,6 +4240,8 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4127
4240
|
marker: 'tr',
|
|
4128
4241
|
content: []
|
|
4129
4242
|
};
|
|
4243
|
+
this.addVidAttributesToNode(rowJsonObj);
|
|
4244
|
+
this.addVidAttributeSecondAttempt(rowJsonObj, node.children[1]);
|
|
4130
4245
|
node.children.slice(1).forEach((child)=>{
|
|
4131
4246
|
this.nodeToUSJ(child, rowJsonObj);
|
|
4132
4247
|
});
|
|
@@ -4146,6 +4261,20 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4146
4261
|
parentJsonObj.content.push(cellJsonObj);
|
|
4147
4262
|
}
|
|
4148
4263
|
}
|
|
4264
|
+
nodeToUSJList(node, parentJsonObj) {
|
|
4265
|
+
const firstChild = node.children.length > 0 ? node.children[0] : null;
|
|
4266
|
+
if (firstChild && firstChild.type === 'list_s') {
|
|
4267
|
+
const listJsonObj = {
|
|
4268
|
+
type: 'list',
|
|
4269
|
+
content: []
|
|
4270
|
+
};
|
|
4271
|
+
this.addVidAttributesToNode(listJsonObj);
|
|
4272
|
+
for(let i = 1; i < node.children.length - 1; i++)this.nodeToUSJ(node.children[i], listJsonObj);
|
|
4273
|
+
parentJsonObj.content.push(listJsonObj);
|
|
4274
|
+
} else node.children.forEach((child)=>{
|
|
4275
|
+
this.nodeToUSJ(child, parentJsonObj);
|
|
4276
|
+
});
|
|
4277
|
+
}
|
|
4149
4278
|
nodeToUSJAttrib(node, parentJsonObj) {
|
|
4150
4279
|
// Add attribute values to USJ elements
|
|
4151
4280
|
const attribNameNode = node.children[0];
|
|
@@ -4175,6 +4304,7 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4175
4304
|
marker: style,
|
|
4176
4305
|
content: []
|
|
4177
4306
|
};
|
|
4307
|
+
this.addVidAttributesToNode(msJsonObj);
|
|
4178
4308
|
node.children.forEach((child)=>{
|
|
4179
4309
|
if (child.type.endsWith('Attribute')) this.nodeToUSJ(child, msJsonObj);
|
|
4180
4310
|
});
|
|
@@ -4190,6 +4320,7 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4190
4320
|
marker: 'esb',
|
|
4191
4321
|
content: []
|
|
4192
4322
|
};
|
|
4323
|
+
this.addVidAttributesToNode(sidebarJsonObj);
|
|
4193
4324
|
node.children.slice(1, -1).forEach((child)=>{
|
|
4194
4325
|
this.nodeToUSJ(child, sidebarJsonObj);
|
|
4195
4326
|
});
|
|
@@ -4205,6 +4336,7 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4205
4336
|
marker: 'fig',
|
|
4206
4337
|
content: []
|
|
4207
4338
|
};
|
|
4339
|
+
this.addVidAttributesToNode(figJsonObj);
|
|
4208
4340
|
node.children.slice(1, -1).forEach((child)=>{
|
|
4209
4341
|
this.nodeToUSJ(child, figJsonObj);
|
|
4210
4342
|
});
|
|
@@ -4220,9 +4352,57 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4220
4352
|
parentJsonObj.content.push(refJsonObj);
|
|
4221
4353
|
}
|
|
4222
4354
|
}
|
|
4355
|
+
nodeToUSJCustom(node, parentJsonObj) {
|
|
4356
|
+
const nodeTypeMap = {
|
|
4357
|
+
zNameSpacePara: 'para',
|
|
4358
|
+
zNameSpaceChar: 'char',
|
|
4359
|
+
zNameSpaceNote: 'note',
|
|
4360
|
+
zNameSpaceMS: 'ms',
|
|
4361
|
+
zNameSpaceRegular: 'para',
|
|
4362
|
+
zNameSpaceCharNested: 'char',
|
|
4363
|
+
zNameSpaceClosed: 'ms'
|
|
4364
|
+
};
|
|
4365
|
+
let currNode = node;
|
|
4366
|
+
let nodeType = null;
|
|
4367
|
+
if (node.type === 'zNameSpaceUndefined' && node.children.length > 0) currNode = node.children[0];
|
|
4368
|
+
if (currNode.type === 'zNameSpaceClosed' && currNode.children.length > 0) {
|
|
4369
|
+
// Undefined marker: take the closing as the cue for the type.
|
|
4370
|
+
// Closed with \marker* implies char, closed with only \* implies ms.
|
|
4371
|
+
const lastChild = currNode.children[currNode.children.length - 1];
|
|
4372
|
+
if (lastChild.type.startsWith('zSpaceClose')) nodeType = 'char';
|
|
4373
|
+
}
|
|
4374
|
+
if (nodeType === null) nodeType = nodeTypeMap[currNode.type];
|
|
4375
|
+
if (nodeType === undefined) {
|
|
4376
|
+
this.errors.push(`Unknown custom node type: ${currNode.type}`);
|
|
4377
|
+
return;
|
|
4378
|
+
}
|
|
4379
|
+
const customJsonObj = {
|
|
4380
|
+
type: nodeType,
|
|
4381
|
+
content: []
|
|
4382
|
+
};
|
|
4383
|
+
// Consume any vid/h pending from a preceding \vid marker, as the other
|
|
4384
|
+
// node handlers do, so it is not left to attach to a later node
|
|
4385
|
+
this.addVidAttributesToNode(customJsonObj);
|
|
4386
|
+
for (const child of currNode.children){
|
|
4387
|
+
if (child.type.startsWith('zSpaceTag')) {
|
|
4388
|
+
// A nested tag keeps its + between the backslash and the type prefix
|
|
4389
|
+
const marker = this.usfm.slice(child.startIndex, child.endIndex).trim().replace('\\', '').replace(/^\+/, '');
|
|
4390
|
+
if (marker.startsWith('custom')) customJsonObj.marker = marker.split('_').slice(1).join('_');
|
|
4391
|
+
else customJsonObj.marker = marker;
|
|
4392
|
+
} else if (child.type.endsWith('Attribute')) this.nodeToUSJ(child, customJsonObj);
|
|
4393
|
+
else if (child.type.startsWith('zSpaceClose')) {
|
|
4394
|
+
const closeMarker = this.usfm.slice(child.startIndex, child.endIndex).trim().replace('\\', '').replace(/^\+/, '');
|
|
4395
|
+
let closedMarker = closeMarker.replace(/\*$/, '');
|
|
4396
|
+
if (closedMarker.startsWith('custom')) closedMarker = closedMarker.split('_').slice(1).join('_');
|
|
4397
|
+
if (closedMarker !== customJsonObj.marker) this.warnings.push(`Custom node closed with a different marker: ${closedMarker} ` + `instead of ${customJsonObj.marker}`);
|
|
4398
|
+
} else if (child.type === 'caller') customJsonObj.caller = this.usfm.slice(child.startIndex, child.endIndex).trim();
|
|
4399
|
+
else this.nodeToUSJ(child, customJsonObj);
|
|
4400
|
+
}
|
|
4401
|
+
parentJsonObj.content.push(customJsonObj);
|
|
4402
|
+
}
|
|
4223
4403
|
nodeToUSJGeneric(node, parentJsonObj) {
|
|
4224
4404
|
// Build nodes for para style markers in USJ
|
|
4225
|
-
const tagNode = node.children[0];
|
|
4405
|
+
const tagNode = node.children[0] ? node.children[0] : node;
|
|
4226
4406
|
let style = this.usfm.substring(tagNode.startIndex, tagNode.endIndex);
|
|
4227
4407
|
if (style.startsWith('\\')) style = style.replace('\\', '').trim();
|
|
4228
4408
|
else style = node.type;
|
|
@@ -4238,6 +4418,8 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4238
4418
|
marker: style,
|
|
4239
4419
|
content: []
|
|
4240
4420
|
};
|
|
4421
|
+
this.addVidAttributesToNode(paraJsonObj);
|
|
4422
|
+
this.addVidAttributeSecondAttempt(paraJsonObj, node.children[childrenRangeStart]);
|
|
4241
4423
|
parentJsonObj.content.push(paraJsonObj);
|
|
4242
4424
|
for(let i = childrenRangeStart; i < node.children.length; i++){
|
|
4243
4425
|
const child = node.children[i];
|
|
@@ -4270,6 +4452,8 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4270
4452
|
thisMap.set('v', bindToClass(this.nodeToUSJVerse));
|
|
4271
4453
|
thisMap.set('id', this.nodeToUSJId.bind(this));
|
|
4272
4454
|
thisMap.set('chapter', this.nodeToUSJChapter.bind(this));
|
|
4455
|
+
thisMap.set('list', this.nodeToUSJList.bind(this));
|
|
4456
|
+
thisMap.set('vid', this.node2UsxVid.bind(this));
|
|
4273
4457
|
// nooop
|
|
4274
4458
|
thisMap.set('usfm', ()=>{});
|
|
4275
4459
|
addHandlers([
|
|
@@ -4291,9 +4475,18 @@ class $1bdca1468aa54399$var$USJGenerator {
|
|
|
4291
4475
|
'tr'
|
|
4292
4476
|
], this.nodeToUSJTable);
|
|
4293
4477
|
addHandlers([
|
|
4294
|
-
'milestone'
|
|
4295
|
-
'zNameSpace'
|
|
4478
|
+
'milestone'
|
|
4296
4479
|
], this.nodeToUSJMilestone);
|
|
4480
|
+
addHandlers([
|
|
4481
|
+
'zNameSpacePara',
|
|
4482
|
+
'zNameSpaceChar',
|
|
4483
|
+
'zNameSpaceNote',
|
|
4484
|
+
'zNameSpaceMS',
|
|
4485
|
+
'zNameSpaceUndefined',
|
|
4486
|
+
'zNameSpaceClosed',
|
|
4487
|
+
'zNameSpaceRegular',
|
|
4488
|
+
'zNameSpaceCharNested'
|
|
4489
|
+
], this.nodeToUSJCustom);
|
|
4297
4490
|
addHandlers([
|
|
4298
4491
|
'esb',
|
|
4299
4492
|
'cat',
|
|
@@ -4373,6 +4566,14 @@ class $0143e94dfd2d689d$var$ListGenerator {
|
|
|
4373
4566
|
if (excludeMarkers && excludeMarkers.includes('id') || includeMarkers && !includeMarkers.includes('id')) return;
|
|
4374
4567
|
} else if (obj.type === 'chapter') this.usjToListC(obj);
|
|
4375
4568
|
else if (obj.type === 'verse') this.usjToListV(obj);
|
|
4569
|
+
else if (obj.type === 'list' && excludeMarkers && !excludeMarkers.includes('list-s/e') || includeMarkers && includeMarkers.includes('list-s/e')) this.list.push([
|
|
4570
|
+
this.book,
|
|
4571
|
+
this.currentChapter,
|
|
4572
|
+
this.currentVerse,
|
|
4573
|
+
'',
|
|
4574
|
+
'list',
|
|
4575
|
+
'list-s'
|
|
4576
|
+
]);
|
|
4376
4577
|
let markerType = obj.type;
|
|
4377
4578
|
const markerName = obj.marker ? obj.marker : '';
|
|
4378
4579
|
if (markerType === 'USJ') // This would occur if the JSON got flattened after removing paragraph markers
|
|
@@ -4397,6 +4598,22 @@ class $0143e94dfd2d689d$var$ListGenerator {
|
|
|
4397
4598
|
markerType,
|
|
4398
4599
|
markerName
|
|
4399
4600
|
]);
|
|
4601
|
+
if (obj.type === 'list' && excludeMarkers && !excludeMarkers.includes('list-s/e') || includeMarkers && includeMarkers.includes('list-s/e')) this.list.push([
|
|
4602
|
+
this.book,
|
|
4603
|
+
this.currentChapter,
|
|
4604
|
+
this.currentVerse,
|
|
4605
|
+
'',
|
|
4606
|
+
'list',
|
|
4607
|
+
'list-e'
|
|
4608
|
+
]);
|
|
4609
|
+
else if (obj.type === 'sidebar' && excludeMarkers && !excludeMarkers.includes('esbe') || includeMarkers && includeMarkers.includes('esbe')) this.list.push([
|
|
4610
|
+
this.book,
|
|
4611
|
+
this.currentChapter,
|
|
4612
|
+
this.currentVerse,
|
|
4613
|
+
'',
|
|
4614
|
+
'sidebar',
|
|
4615
|
+
'esbe'
|
|
4616
|
+
]);
|
|
4400
4617
|
}
|
|
4401
4618
|
usjToBibleNlpFormat(obj) {
|
|
4402
4619
|
// Traverse the USJ object and build a dictionary for Bible NLP format
|
|
@@ -4433,11 +4650,13 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4433
4650
|
*/ constructor(treeSitterLanguageObj, usfmString, usxRootElement = null){
|
|
4434
4651
|
this.usfmLanguage = treeSitterLanguageObj;
|
|
4435
4652
|
this.usfm = usfmString;
|
|
4653
|
+
this.warnings = []; // Initialize warnings array to store any warnings during processing
|
|
4654
|
+
this.errors = [];
|
|
4436
4655
|
const domImpl = new (0, $5OpyM$DOMImplementation)();
|
|
4437
4656
|
const doc = domImpl.createDocument(null, 'usx', null);
|
|
4438
4657
|
if (usxRootElement === null) {
|
|
4439
4658
|
this.xmlRootNode = doc.documentElement;
|
|
4440
|
-
this.xmlRootNode.setAttribute('version',
|
|
4659
|
+
this.xmlRootNode.setAttribute('version', (0, $28b0061e56e1edf2$export$7dc487a0fa1a604f));
|
|
4441
4660
|
} else this.xmlRootNode = usxRootElement;
|
|
4442
4661
|
// Cache for the query objects
|
|
4443
4662
|
this.queries = {};
|
|
@@ -4452,7 +4671,9 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4452
4671
|
currentChapter: null,
|
|
4453
4672
|
prevVerseSid: null,
|
|
4454
4673
|
prevChapterSid: null,
|
|
4455
|
-
prevVerse: null
|
|
4674
|
+
prevVerse: null,
|
|
4675
|
+
vidH: null,
|
|
4676
|
+
vidRef: null
|
|
4456
4677
|
};
|
|
4457
4678
|
// maps and id to a fn;
|
|
4458
4679
|
this.dispatchMap = this.populateDispatchMap();
|
|
@@ -4470,6 +4691,8 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4470
4691
|
thisMap.set('v', bindToClass(this.node2UsxVerse));
|
|
4471
4692
|
thisMap.set('id', this.node2UsxId.bind(this));
|
|
4472
4693
|
thisMap.set('chapter', this.node2UsxChapter.bind(this));
|
|
4694
|
+
thisMap.set('list', this.node2UsxList.bind(this));
|
|
4695
|
+
thisMap.set('vid', this.node2UsxVid.bind(this));
|
|
4473
4696
|
// nooop
|
|
4474
4697
|
thisMap.set('usfm', ()=>{});
|
|
4475
4698
|
addHandlers([
|
|
@@ -4492,9 +4715,18 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4492
4715
|
'tr'
|
|
4493
4716
|
], this.node2UsxTable);
|
|
4494
4717
|
addHandlers([
|
|
4495
|
-
'milestone'
|
|
4496
|
-
'zNameSpace'
|
|
4718
|
+
'milestone'
|
|
4497
4719
|
], this.node2UsxMilestone);
|
|
4720
|
+
addHandlers([
|
|
4721
|
+
'zNameSpacePara',
|
|
4722
|
+
'zNameSpaceChar',
|
|
4723
|
+
'zNameSpaceNote',
|
|
4724
|
+
'zNameSpaceMS',
|
|
4725
|
+
'zNameSpaceUndefined',
|
|
4726
|
+
'zNameSpaceClosed',
|
|
4727
|
+
'zNameSpaceRegular',
|
|
4728
|
+
'zNameSpaceCharNested'
|
|
4729
|
+
], this.node2UsxCustom);
|
|
4498
4730
|
addHandlers([
|
|
4499
4731
|
'esb',
|
|
4500
4732
|
'cat',
|
|
@@ -4661,6 +4893,45 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4661
4893
|
// Append the 'char' element to the parent XML node
|
|
4662
4894
|
parentXmlNode.appendChild(charXmlNode);
|
|
4663
4895
|
}
|
|
4896
|
+
node2UsxVid(node, _parentXmlNode) {
|
|
4897
|
+
// Build elements for vid and h attributes
|
|
4898
|
+
this.parseState.vidH = null;
|
|
4899
|
+
for (const child of node.children){
|
|
4900
|
+
let attribValue = null;
|
|
4901
|
+
for (const innerChild of child.children)if (innerChild.type === 'attributeValue') {
|
|
4902
|
+
attribValue = this.usfm.slice(innerChild.startIndex, innerChild.endIndex).trim();
|
|
4903
|
+
break;
|
|
4904
|
+
}
|
|
4905
|
+
if (child.type === 'hAttribute') this.parseState.vidH = attribValue;
|
|
4906
|
+
else if (child.type === 'refAttribute') this.parseState.vidRef = attribValue;
|
|
4907
|
+
else if (child.type === 'defaultAttribute') this.parseState.vidRef = attribValue;
|
|
4908
|
+
}
|
|
4909
|
+
if (this.parseState.vidRef) {
|
|
4910
|
+
const refMatch = this.parseState.vidRef.match((0, $28b0061e56e1edf2$export$8e480ab8367e6dbc));
|
|
4911
|
+
if (refMatch) {
|
|
4912
|
+
this.parseState.bookSlug = refMatch[1];
|
|
4913
|
+
this.parseState.currentChapter = refMatch[2];
|
|
4914
|
+
} else {
|
|
4915
|
+
this.warnings.push(`vid-ref attribute value does not match expected pattern: ${this.parseState.vidRef}`);
|
|
4916
|
+
this.parseState.vidRef = null; // Reset vidRef if it doesn't match the expected pattern
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
}
|
|
4920
|
+
addVidAttributesToNode(parentXmlNode) {
|
|
4921
|
+
//Add vid attributes to the given xml node if they exist in parse state
|
|
4922
|
+
if (this.parseState.vidH) {
|
|
4923
|
+
parentXmlNode.setAttribute('h', this.parseState.vidH);
|
|
4924
|
+
this.parseState.vidH = null; // Reset after use
|
|
4925
|
+
}
|
|
4926
|
+
if (this.parseState.vidRef) {
|
|
4927
|
+
parentXmlNode.setAttribute('vid', this.parseState.vidRef);
|
|
4928
|
+
this.parseState.vidRef = null; // Reset after use
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
addVidAttributesSecondAttempt(xmlNode, firstChild) {
|
|
4932
|
+
// Add vid attributes to the given xml node if firstChild is not a verse tag
|
|
4933
|
+
if (!xmlNode.hasAttribute('vid') && this.parseState.prevVerseSid && firstChild && firstChild.type !== 'v') xmlNode.setAttribute('vid', this.parseState.prevVerseSid);
|
|
4934
|
+
}
|
|
4664
4935
|
node2UsxPara(node, parentXmlNode) {
|
|
4665
4936
|
// Build paragraph nodes in USX
|
|
4666
4937
|
if (node.children[0].type.endsWith('Block')) for (const child of node.children[0].children)this.node2UsxPara(child, parentXmlNode);
|
|
@@ -4670,6 +4941,8 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4670
4941
|
if (!paraMarker.endsWith('Block')) {
|
|
4671
4942
|
const paraXmlNode = parentXmlNode.ownerDocument.createElement('para');
|
|
4672
4943
|
paraXmlNode.setAttribute('style', paraMarker);
|
|
4944
|
+
this.addVidAttributesToNode(paraXmlNode);
|
|
4945
|
+
this.addVidAttributesSecondAttempt(paraXmlNode, paraTagCap.node.children[1]);
|
|
4673
4946
|
parentXmlNode.appendChild(paraXmlNode);
|
|
4674
4947
|
for (const child of paraTagCap.node.children.slice(1))this.node2Usx(child, paraXmlNode);
|
|
4675
4948
|
}
|
|
@@ -4680,6 +4953,8 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4680
4953
|
const paraMarker = this.usfm.slice(node.children[0].startIndex, node.children[0].endIndex).replace('\\', '').trim();
|
|
4681
4954
|
const paraXmlNode = parentXmlNode.ownerDocument.createElement('para');
|
|
4682
4955
|
paraXmlNode.setAttribute('style', paraMarker);
|
|
4956
|
+
this.addVidAttributesToNode(paraXmlNode);
|
|
4957
|
+
this.addVidAttributesSecondAttempt(paraXmlNode, node.children[1]);
|
|
4683
4958
|
parentXmlNode.appendChild(paraXmlNode);
|
|
4684
4959
|
for (const child of node.children.slice(1))this.node2Usx(child, paraXmlNode);
|
|
4685
4960
|
}
|
|
@@ -4693,6 +4968,7 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4693
4968
|
noteXmlNode.setAttribute('style', style);
|
|
4694
4969
|
const caller = this.usfm.substring(callerNode.startIndex, callerNode.endIndex).trim();
|
|
4695
4970
|
noteXmlNode.setAttribute('caller', caller);
|
|
4971
|
+
this.addVidAttributesToNode(noteXmlNode);
|
|
4696
4972
|
parentXmlNode.appendChild(noteXmlNode);
|
|
4697
4973
|
for(let i = 2; i < node.children.length - 1; i++)this.node2Usx(node.children[i], noteXmlNode);
|
|
4698
4974
|
}
|
|
@@ -4700,10 +4976,18 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4700
4976
|
// Build USJ nodes for character markups, both regular and nested
|
|
4701
4977
|
const tagNode = node.children[0];
|
|
4702
4978
|
let childrenRange = node.children.length;
|
|
4703
|
-
|
|
4979
|
+
let closingNode = null;
|
|
4980
|
+
for(let i = node.children.length - 1; i > 0; i--){
|
|
4981
|
+
if (node.children[i].type.startsWith('\\') || node.children[i].type === '*' || node.children[i].type.endsWith('Tag')) {
|
|
4982
|
+
childrenRange -= 1;
|
|
4983
|
+
closingNode = node.children[i];
|
|
4984
|
+
} else break;
|
|
4985
|
+
}
|
|
4704
4986
|
const charXmlNode = parentXmlNode.ownerDocument.createElement('char');
|
|
4705
4987
|
const style = this.usfm.substring(tagNode.startIndex, tagNode.endIndex).replace('\\', '').replace('+', '').trim();
|
|
4706
4988
|
charXmlNode.setAttribute('style', style);
|
|
4989
|
+
if (closingNode) charXmlNode.setAttribute('closed', 'true');
|
|
4990
|
+
else charXmlNode.setAttribute('closed', 'false');
|
|
4707
4991
|
parentXmlNode.appendChild(charXmlNode);
|
|
4708
4992
|
for(let i = 1; i < childrenRange; i++)this.node2Usx(node.children[i], charXmlNode);
|
|
4709
4993
|
}
|
|
@@ -4736,6 +5020,8 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4736
5020
|
const rowXmlNode = parentXmlNode.ownerDocument.createElement('row');
|
|
4737
5021
|
rowXmlNode.setAttribute('style', 'tr');
|
|
4738
5022
|
parentXmlNode.appendChild(rowXmlNode);
|
|
5023
|
+
this.addVidAttributesToNode(rowXmlNode);
|
|
5024
|
+
this.addVidAttributesSecondAttempt(rowXmlNode, node.children[1]);
|
|
4739
5025
|
node.children.slice(1).forEach((child)=>{
|
|
4740
5026
|
this.node2Usx(child, rowXmlNode);
|
|
4741
5027
|
});
|
|
@@ -4751,22 +5037,78 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4751
5037
|
});
|
|
4752
5038
|
}
|
|
4753
5039
|
}
|
|
5040
|
+
node2UsxList(node, parentXmlNode) {
|
|
5041
|
+
const firstChild = node.children.length > 0 ? node.children[0] : null;
|
|
5042
|
+
if (firstChild && firstChild.type === 'list_s') {
|
|
5043
|
+
const listXmlNode = parentXmlNode.ownerDocument.createElement('list');
|
|
5044
|
+
this.addVidAttributesToNode(listXmlNode);
|
|
5045
|
+
for(let i = 1; i < node.children.length - 1; i++)this.node2Usx(node.children[i], listXmlNode);
|
|
5046
|
+
parentXmlNode.appendChild(listXmlNode);
|
|
5047
|
+
} else for (const child of node.children)this.node2Usx(child, parentXmlNode);
|
|
5048
|
+
}
|
|
4754
5049
|
node2UsxMilestone(node, parentXmlNode) {
|
|
4755
5050
|
// Create ms node in USJ
|
|
4756
5051
|
const msNameCap = this.getQuery('milestone').captures(node)[0]; //
|
|
4757
5052
|
const style = this.usfm.slice(msNameCap.node.startIndex, msNameCap.node.endIndex).replace('\\', '').trim();
|
|
4758
5053
|
const msXmlNode = parentXmlNode.ownerDocument.createElement('ms');
|
|
4759
5054
|
msXmlNode.setAttribute('style', style);
|
|
5055
|
+
this.addVidAttributesToNode(msXmlNode);
|
|
4760
5056
|
parentXmlNode.appendChild(msXmlNode);
|
|
4761
5057
|
node.children.forEach((child)=>{
|
|
4762
5058
|
if (child.type.endsWith('Attribute')) this.node2Usx(child, msXmlNode);
|
|
4763
5059
|
});
|
|
4764
5060
|
}
|
|
5061
|
+
node2UsxCustom(node, parentXmlNode) {
|
|
5062
|
+
const nodeTypeMap = {
|
|
5063
|
+
zNameSpacePara: 'para',
|
|
5064
|
+
zNameSpaceChar: 'char',
|
|
5065
|
+
zNameSpaceNote: 'note',
|
|
5066
|
+
zNameSpaceMS: 'ms',
|
|
5067
|
+
zNameSpaceRegular: 'para',
|
|
5068
|
+
zNameSpaceCharNested: 'char',
|
|
5069
|
+
zNameSpaceClosed: 'ms'
|
|
5070
|
+
};
|
|
5071
|
+
let currNode = node;
|
|
5072
|
+
let nodeType = null;
|
|
5073
|
+
if (node.type === 'zNameSpaceUndefined' && node.children.length > 0) currNode = node.children[0];
|
|
5074
|
+
if (currNode.type === 'zNameSpaceClosed' && currNode.children.length > 0) {
|
|
5075
|
+
// Undefined marker: take the closing as the cue for the type.
|
|
5076
|
+
// Closed with \marker* implies char, closed with only \* implies ms.
|
|
5077
|
+
const lastChild = currNode.children[currNode.children.length - 1];
|
|
5078
|
+
if (lastChild.type.startsWith('zSpaceClose')) nodeType = 'char';
|
|
5079
|
+
}
|
|
5080
|
+
if (nodeType === null) nodeType = nodeTypeMap[currNode.type];
|
|
5081
|
+
if (nodeType === undefined) {
|
|
5082
|
+
this.errors.push(`Unknown custom node type: ${node.type}`);
|
|
5083
|
+
return;
|
|
5084
|
+
}
|
|
5085
|
+
const customXmlNode = parentXmlNode.ownerDocument.createElement(nodeType);
|
|
5086
|
+
// Consume any vid/h pending from a preceding \vid marker, as the other
|
|
5087
|
+
// node handlers do, so it is not left to attach to a later node
|
|
5088
|
+
this.addVidAttributesToNode(customXmlNode);
|
|
5089
|
+
for (const child of currNode.children){
|
|
5090
|
+
if (child.type.startsWith('zSpaceTag')) {
|
|
5091
|
+
// A nested tag keeps its + between the backslash and the type prefix
|
|
5092
|
+
let marker = this.usfm.slice(child.startIndex, child.endIndex).trim().replace('\\', '').replace(/^\+/, '');
|
|
5093
|
+
if (marker.startsWith('custom')) marker = marker.split('_').slice(1).join('_');
|
|
5094
|
+
customXmlNode.setAttribute('style', marker);
|
|
5095
|
+
} else if (child.type.endsWith('Attribute')) this.node2Usx(child, customXmlNode);
|
|
5096
|
+
else if (child.type.startsWith('zSpaceClose')) {
|
|
5097
|
+
const closeMarker = this.usfm.slice(child.startIndex, child.endIndex).trim().replace('\\', '').replace(/^\+/, '');
|
|
5098
|
+
let closedMarker = closeMarker.replace(/\*$/, '');
|
|
5099
|
+
if (closeMarker.startsWith('custom')) closedMarker = closedMarker.split('_').slice(1).join('_');
|
|
5100
|
+
if (closedMarker !== customXmlNode.getAttribute('style')) this.warnings.push(`Custom node closed with a different marker: ${closedMarker} ` + `instead of ${customXmlNode.getAttribute('style')}`);
|
|
5101
|
+
} else if (child.type === 'caller') customXmlNode.setAttribute('caller', this.usfm.slice(child.startIndex, child.endIndex).trim());
|
|
5102
|
+
else this.node2Usx(child, customXmlNode);
|
|
5103
|
+
}
|
|
5104
|
+
parentXmlNode.appendChild(customXmlNode);
|
|
5105
|
+
}
|
|
4765
5106
|
node2UsxSpecial(node, parentXmlNode) {
|
|
4766
5107
|
// Build nodes for esb, cat, fig, optbreak in USJ
|
|
4767
5108
|
if (node.type === 'esb') {
|
|
4768
5109
|
const sidebarXmlNode = parentXmlNode.ownerDocument.createElement('sidebar');
|
|
4769
5110
|
sidebarXmlNode.setAttribute('style', 'esb');
|
|
5111
|
+
this.addVidAttributesToNode(sidebarXmlNode);
|
|
4770
5112
|
parentXmlNode.appendChild(sidebarXmlNode);
|
|
4771
5113
|
node.children.slice(1, -1).forEach((child)=>{
|
|
4772
5114
|
this.node2Usx(child, sidebarXmlNode);
|
|
@@ -4778,6 +5120,7 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4778
5120
|
} else if (node.type === 'fig') {
|
|
4779
5121
|
const figXmlNode = parentXmlNode.ownerDocument.createElement('figure');
|
|
4780
5122
|
figXmlNode.setAttribute('style', 'fig');
|
|
5123
|
+
this.addVidAttributesToNode(figXmlNode);
|
|
4781
5124
|
parentXmlNode.appendChild(figXmlNode);
|
|
4782
5125
|
node.children.slice(1, -1).forEach((child)=>{
|
|
4783
5126
|
this.node2Usx(child, figXmlNode);
|
|
@@ -4791,7 +5134,7 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4791
5134
|
}
|
|
4792
5135
|
}
|
|
4793
5136
|
node2UsxGeneric(node, parentXmlNode) {
|
|
4794
|
-
const tagNode = node.children[0];
|
|
5137
|
+
const tagNode = node.children[0] ? node.children[0] : node;
|
|
4795
5138
|
let style = this.usfm.slice(tagNode.startIndex, tagNode.endIndex).trim();
|
|
4796
5139
|
// Strip leading backslashes from the style or use node type
|
|
4797
5140
|
if (style.startsWith('\\')) style = style.replace('\\', '');
|
|
@@ -4802,6 +5145,8 @@ class $02bc2da10d8b76e8$var$USXGenerator {
|
|
|
4802
5145
|
const paraXmlNode = parentXmlNode.ownerDocument.createElement('para');
|
|
4803
5146
|
paraXmlNode.setAttribute('style', style);
|
|
4804
5147
|
parentXmlNode.appendChild(paraXmlNode);
|
|
5148
|
+
this.addVidAttributesToNode(paraXmlNode);
|
|
5149
|
+
this.addVidAttributesSecondAttempt(paraXmlNode, node.children[childrenRangeStart]);
|
|
4805
5150
|
// Loop through the child nodes and recursively process them
|
|
4806
5151
|
for(let i = childrenRangeStart; i < node.children.length; i++){
|
|
4807
5152
|
const child = node.children[i];
|
|
@@ -46766,6 +47111,7 @@ const $ab5c81e737a0c6a6$var$MARKERS_WITH_DISCARDABLE_CONTENTS = [
|
|
|
46766
47111
|
'ipq',
|
|
46767
47112
|
'imq',
|
|
46768
47113
|
'ipr',
|
|
47114
|
+
'ipc',
|
|
46769
47115
|
'iq',
|
|
46770
47116
|
'ib',
|
|
46771
47117
|
'ili',
|
|
@@ -46819,11 +47165,13 @@ const $ab5c81e737a0c6a6$var$MARKERS_WITH_DISCARDABLE_CONTENTS = [
|
|
|
46819
47165
|
'fig',
|
|
46820
47166
|
'cat',
|
|
46821
47167
|
'esb',
|
|
46822
|
-
'b'
|
|
47168
|
+
'b',
|
|
47169
|
+
'user-extension'
|
|
46823
47170
|
];
|
|
46824
47171
|
const $ab5c81e737a0c6a6$var$trailingNumPattern = /\d+$/;
|
|
46825
47172
|
const $ab5c81e737a0c6a6$var$punctPatternNoSpaceBefore = /^[,.\-—/;:!?@$%^)}\]>”»]/;
|
|
46826
47173
|
const $ab5c81e737a0c6a6$var$punctPatternNoSpaceAfter = /[\-—/`@^&({[<“«]$/;
|
|
47174
|
+
const $ab5c81e737a0c6a6$var$znamespacePattern = /^z[\w\-]+/;
|
|
46827
47175
|
function $ab5c81e737a0c6a6$var$combineConsecutiveTextContents(contentsList) {
|
|
46828
47176
|
const textCombinedContents = [];
|
|
46829
47177
|
let textContents = '';
|
|
@@ -46842,6 +47190,28 @@ function $ab5c81e737a0c6a6$var$combineConsecutiveTextContents(contentsList) {
|
|
|
46842
47190
|
if (textContents !== '') textCombinedContents.push(textContents);
|
|
46843
47191
|
return textCombinedContents;
|
|
46844
47192
|
}
|
|
47193
|
+
function $ab5c81e737a0c6a6$var$deepCopyValue(value) {
|
|
47194
|
+
// Plain-JSON deep copy; primitives are immutable so they are returned as is
|
|
47195
|
+
if (value === null || typeof value !== 'object') return value;
|
|
47196
|
+
if (Array.isArray(value)) return value.map($ab5c81e737a0c6a6$var$deepCopyValue);
|
|
47197
|
+
const copied = {};
|
|
47198
|
+
Object.keys(value).forEach((key)=>{
|
|
47199
|
+
copied[key] = $ab5c81e737a0c6a6$var$deepCopyValue(value[key]);
|
|
47200
|
+
});
|
|
47201
|
+
return copied;
|
|
47202
|
+
}
|
|
47203
|
+
function $ab5c81e737a0c6a6$var$copyUsjNode(inputUsj, cleanedKids) {
|
|
47204
|
+
// Build a copy, rather than mutate the caller's USJ object.
|
|
47205
|
+
// 'content' is already rebuilt from the filtered children, so only the other
|
|
47206
|
+
// values need a deep copy. That keeps the copying linear, and keeps any
|
|
47207
|
+
// non-primitive value from being shared between the input and the output.
|
|
47208
|
+
const cleanedUsj = {};
|
|
47209
|
+
Object.keys(inputUsj).forEach((key)=>{
|
|
47210
|
+
cleanedUsj[key] = key === 'content' ? inputUsj[key] : $ab5c81e737a0c6a6$var$deepCopyValue(inputUsj[key]);
|
|
47211
|
+
});
|
|
47212
|
+
cleanedUsj.content = cleanedKids;
|
|
47213
|
+
return cleanedUsj;
|
|
47214
|
+
}
|
|
46845
47215
|
function $ab5c81e737a0c6a6$var$excludeMarkersInUsj(inputUsj, excludeMarkers, combineTexts = true, excludedParent = false) {
|
|
46846
47216
|
let cleanedKids = [];
|
|
46847
47217
|
if (typeof inputUsj === 'string') {
|
|
@@ -46851,8 +47221,10 @@ function $ab5c81e737a0c6a6$var$excludeMarkersInUsj(inputUsj, excludeMarkers, com
|
|
|
46851
47221
|
];
|
|
46852
47222
|
}
|
|
46853
47223
|
let thisMarker = '';
|
|
47224
|
+
if (inputUsj.type === 'list') thisMarker = 'list-s/e';
|
|
46854
47225
|
if ('marker' in inputUsj) thisMarker = inputUsj.marker.replace($ab5c81e737a0c6a6$var$trailingNumPattern, '');
|
|
46855
47226
|
else if (inputUsj.type === 'ref') thisMarker = 'ref';
|
|
47227
|
+
if ($ab5c81e737a0c6a6$var$znamespacePattern.test(thisMarker)) thisMarker = 'user-extension';
|
|
46856
47228
|
let thisMarkerNeeded = true;
|
|
46857
47229
|
let innerContentNeeded = true;
|
|
46858
47230
|
excludedParent = false;
|
|
@@ -46869,10 +47241,7 @@ function $ab5c81e737a0c6a6$var$excludeMarkersInUsj(inputUsj, excludeMarkers, com
|
|
|
46869
47241
|
});
|
|
46870
47242
|
if (combineTexts) cleanedKids = $ab5c81e737a0c6a6$var$combineConsecutiveTextContents(cleanedKids);
|
|
46871
47243
|
}
|
|
46872
|
-
if (thisMarkerNeeded)
|
|
46873
|
-
inputUsj.content = cleanedKids;
|
|
46874
|
-
return inputUsj;
|
|
46875
|
-
}
|
|
47244
|
+
if (thisMarkerNeeded) return $ab5c81e737a0c6a6$var$copyUsjNode(inputUsj, cleanedKids);
|
|
46876
47245
|
if (innerContentNeeded) return cleanedKids;
|
|
46877
47246
|
return [];
|
|
46878
47247
|
}
|
|
@@ -46885,8 +47254,10 @@ function $ab5c81e737a0c6a6$var$includeMarkersInUsj(inputUsj, includeMarkers, com
|
|
|
46885
47254
|
];
|
|
46886
47255
|
}
|
|
46887
47256
|
let thisMarker = '';
|
|
47257
|
+
if (inputUsj.type === 'list') thisMarker = 'list-s/e';
|
|
46888
47258
|
if ('marker' in inputUsj) thisMarker = inputUsj.marker.replace($ab5c81e737a0c6a6$var$trailingNumPattern, '');
|
|
46889
47259
|
else if (inputUsj.type === 'ref') thisMarker = 'ref';
|
|
47260
|
+
if ($ab5c81e737a0c6a6$var$znamespacePattern.test(thisMarker)) thisMarker = 'user-extension';
|
|
46890
47261
|
const thisMarkerNeeded = includeMarkers.includes(thisMarker) || thisMarker === '';
|
|
46891
47262
|
const innerContentNeeded = thisMarkerNeeded || !$ab5c81e737a0c6a6$var$MARKERS_WITH_DISCARDABLE_CONTENTS.includes(thisMarker);
|
|
46892
47263
|
if (innerContentNeeded && 'content' in inputUsj) {
|
|
@@ -46897,16 +47268,16 @@ function $ab5c81e737a0c6a6$var$includeMarkersInUsj(inputUsj, includeMarkers, com
|
|
|
46897
47268
|
});
|
|
46898
47269
|
if (combineTexts) cleanedKids = $ab5c81e737a0c6a6$var$combineConsecutiveTextContents(cleanedKids);
|
|
46899
47270
|
}
|
|
46900
|
-
if (thisMarker === 'c') {
|
|
46901
|
-
if (!includeMarkers.includes('ca')) delete inputUsj.altnumber;
|
|
46902
|
-
if (!includeMarkers.includes('cp')) delete inputUsj.pubnumber;
|
|
46903
|
-
} else if (thisMarker === 'v') {
|
|
46904
|
-
if (!includeMarkers.includes('va')) delete inputUsj.altnumber;
|
|
46905
|
-
if (!includeMarkers.includes('vp')) delete inputUsj.pubnumber;
|
|
46906
|
-
}
|
|
46907
47271
|
if (thisMarkerNeeded) {
|
|
46908
|
-
|
|
46909
|
-
|
|
47272
|
+
const cleanedUsj = $ab5c81e737a0c6a6$var$copyUsjNode(inputUsj, cleanedKids);
|
|
47273
|
+
if (thisMarker === 'c') {
|
|
47274
|
+
if (!includeMarkers.includes('ca')) delete cleanedUsj.altnumber;
|
|
47275
|
+
if (!includeMarkers.includes('cp')) delete cleanedUsj.pubnumber;
|
|
47276
|
+
} else if (thisMarker === 'v') {
|
|
47277
|
+
if (!includeMarkers.includes('va')) delete cleanedUsj.altnumber;
|
|
47278
|
+
if (!includeMarkers.includes('vp')) delete cleanedUsj.pubnumber;
|
|
47279
|
+
}
|
|
47280
|
+
return cleanedUsj;
|
|
46910
47281
|
}
|
|
46911
47282
|
if (innerContentNeeded) return cleanedKids;
|
|
46912
47283
|
return [];
|
|
@@ -46928,6 +47299,7 @@ class $ab5c81e737a0c6a6$export$ec91da630f36d5ea {
|
|
|
46928
47299
|
'ipq',
|
|
46929
47300
|
'imq',
|
|
46930
47301
|
'ipr',
|
|
47302
|
+
'ipc',
|
|
46931
47303
|
'iq',
|
|
46932
47304
|
'ib',
|
|
46933
47305
|
'ili',
|
|
@@ -47011,6 +47383,8 @@ class $ab5c81e737a0c6a6$export$ec91da630f36d5ea {
|
|
|
47011
47383
|
'sls',
|
|
47012
47384
|
'tl',
|
|
47013
47385
|
'wj',
|
|
47386
|
+
'ta',
|
|
47387
|
+
'wl',
|
|
47014
47388
|
'em',
|
|
47015
47389
|
'bd',
|
|
47016
47390
|
'bdit',
|
|
@@ -47064,10 +47438,23 @@ class $ab5c81e737a0c6a6$export$ec91da630f36d5ea {
|
|
|
47064
47438
|
'c',
|
|
47065
47439
|
'v'
|
|
47066
47440
|
];
|
|
47441
|
+
static LISTS = [
|
|
47442
|
+
'list-s',
|
|
47443
|
+
'list-e',
|
|
47444
|
+
'lh',
|
|
47445
|
+
'li',
|
|
47446
|
+
'lf',
|
|
47447
|
+
'lim',
|
|
47448
|
+
'lik',
|
|
47449
|
+
'liv'
|
|
47450
|
+
];
|
|
47067
47451
|
static TEXT = [
|
|
47068
47452
|
'text-in-excluded-parent',
|
|
47069
47453
|
'text'
|
|
47070
47454
|
];
|
|
47455
|
+
static ZNAMESPACES = [
|
|
47456
|
+
'user-extension'
|
|
47457
|
+
];
|
|
47071
47458
|
static keepOnly(inputUsj, includeMarkers, combineTexts = true) {
|
|
47072
47459
|
// let flattenedList = [].concat(...includeMarkers);
|
|
47073
47460
|
const cleanedMarkers = includeMarkers.map((marker)=>marker.replace($ab5c81e737a0c6a6$var$trailingNumPattern, ''));
|
|
@@ -47083,6 +47470,115 @@ class $ab5c81e737a0c6a6$export$ec91da630f36d5ea {
|
|
|
47083
47470
|
}
|
|
47084
47471
|
|
|
47085
47472
|
|
|
47473
|
+
const $b0abb17ac2d74d5e$export$ca0f3793b4450a5d = {
|
|
47474
|
+
para: 'para',
|
|
47475
|
+
header: 'para',
|
|
47476
|
+
title: 'para',
|
|
47477
|
+
introduction: 'para',
|
|
47478
|
+
section: 'para',
|
|
47479
|
+
versepara: 'para',
|
|
47480
|
+
list: 'para',
|
|
47481
|
+
otherpara: 'para',
|
|
47482
|
+
note: 'note',
|
|
47483
|
+
crossreference: 'note',
|
|
47484
|
+
footnote: 'note',
|
|
47485
|
+
char: 'char',
|
|
47486
|
+
introchar: 'char',
|
|
47487
|
+
listchar: 'char',
|
|
47488
|
+
footnotechar: 'char',
|
|
47489
|
+
crossreferencechar: 'char',
|
|
47490
|
+
milestone: 'milestone'
|
|
47491
|
+
};
|
|
47492
|
+
const $b0abb17ac2d74d5e$export$15add78feb2cf2fb = {
|
|
47493
|
+
para: 'customPara_',
|
|
47494
|
+
char: 'customChar_',
|
|
47495
|
+
note: 'customNote_',
|
|
47496
|
+
milestone: 'customMS_'
|
|
47497
|
+
};
|
|
47498
|
+
const $b0abb17ac2d74d5e$var$linePattern = /^\\([\w-]+)\s+(.*)$/;
|
|
47499
|
+
// A marker name ends at the first whitespace
|
|
47500
|
+
const $b0abb17ac2d74d5e$var$markerNamePattern = /^\S+/;
|
|
47501
|
+
// \, * and | are USFM structural characters and are never part of a marker name
|
|
47502
|
+
const $b0abb17ac2d74d5e$var$invalidMarkerChars = /[\\*|]/;
|
|
47503
|
+
// The grammar accepts z followed by one or more word or hyphen characters, so
|
|
47504
|
+
// anything else would be rewritten into a tag the parser cannot match
|
|
47505
|
+
const $b0abb17ac2d74d5e$var$customMarkerPattern = /^z[\w-]+$/;
|
|
47506
|
+
// Take the marker name up to the first whitespace and validate it
|
|
47507
|
+
function $b0abb17ac2d74d5e$var$readMarkerName(value) {
|
|
47508
|
+
const nameMatch = value.match($b0abb17ac2d74d5e$var$markerNamePattern);
|
|
47509
|
+
const markerName = nameMatch === null ? '' : nameMatch[0];
|
|
47510
|
+
const invalidMatch = markerName.match($b0abb17ac2d74d5e$var$invalidMarkerChars);
|
|
47511
|
+
if (invalidMatch !== null) throw new Error(`Invalid character '${invalidMatch[0]}' in marker name ` + `'${markerName}'. A marker name cannot contain \\, * or |.`);
|
|
47512
|
+
if (markerName.startsWith('z') && !$b0abb17ac2d74d5e$var$customMarkerPattern.test(markerName)) throw new Error(`Invalid custom marker name '${markerName}'. A custom marker name must be ` + "'z' followed by one or more letters, digits, underscores or hyphens.");
|
|
47513
|
+
return markerName;
|
|
47514
|
+
}
|
|
47515
|
+
// Trim the category value and check that it is one we know
|
|
47516
|
+
function $b0abb17ac2d74d5e$var$readCategory(value) {
|
|
47517
|
+
const category = value.trim();
|
|
47518
|
+
if (!Object.prototype.hasOwnProperty.call($b0abb17ac2d74d5e$export$ca0f3793b4450a5d, category)) throw new Error(`Invalid category '${category}'. Expected one of: ` + `${Object.keys($b0abb17ac2d74d5e$export$ca0f3793b4450a5d).sort().join(', ')}.`);
|
|
47519
|
+
return category;
|
|
47520
|
+
}
|
|
47521
|
+
// Every custom marker block must declare a category
|
|
47522
|
+
function $b0abb17ac2d74d5e$var$checkCategoriesPresent(extensions) {
|
|
47523
|
+
const missing = Object.keys(extensions).filter((name)=>!Object.prototype.hasOwnProperty.call(extensions[name], 'category'));
|
|
47524
|
+
if (missing.length > 0) throw new Error(`Missing category for custom marker(s): ${missing.join(', ')}. ` + 'Every marker block needs a category line.');
|
|
47525
|
+
}
|
|
47526
|
+
// Marker names come from free text in markers.ext, so they may contain regex
|
|
47527
|
+
// metacharacters. Escape them before building a pattern.
|
|
47528
|
+
function $b0abb17ac2d74d5e$var$escapeRegExp(str) {
|
|
47529
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
47530
|
+
}
|
|
47531
|
+
class $b0abb17ac2d74d5e$export$a014771799102136 {
|
|
47532
|
+
constructor(){
|
|
47533
|
+
this.lines = [];
|
|
47534
|
+
this.extensions = {};
|
|
47535
|
+
}
|
|
47536
|
+
readToObject(fileContent = null, filePath = null) {
|
|
47537
|
+
this.lines = [];
|
|
47538
|
+
this.extensions = {};
|
|
47539
|
+
if (fileContent === null && filePath !== null) throw new Error('Reading from a file path is not supported in the browser.');
|
|
47540
|
+
if (fileContent === null) throw new TypeError('fileContent is required.');
|
|
47541
|
+
this.lines = fileContent.split(/\r?\n/);
|
|
47542
|
+
// Build into a local object so a validation error leaves no partial state
|
|
47543
|
+
const extensions = {};
|
|
47544
|
+
let currentMarker = null;
|
|
47545
|
+
for (const line of this.lines){
|
|
47546
|
+
const lineMatch = line.match($b0abb17ac2d74d5e$var$linePattern);
|
|
47547
|
+
if (lineMatch === null) continue;
|
|
47548
|
+
const [, key, value] = lineMatch;
|
|
47549
|
+
if (key === 'marker') {
|
|
47550
|
+
const markerName = $b0abb17ac2d74d5e$var$readMarkerName(value);
|
|
47551
|
+
if (markerName.startsWith('z')) {
|
|
47552
|
+
extensions[markerName] = {};
|
|
47553
|
+
currentMarker = markerName;
|
|
47554
|
+
} else currentMarker = null;
|
|
47555
|
+
} else if (currentMarker !== null) extensions[currentMarker][key] = key === 'category' ? $b0abb17ac2d74d5e$var$readCategory(value) : value;
|
|
47556
|
+
}
|
|
47557
|
+
$b0abb17ac2d74d5e$var$checkCategoriesPresent(extensions);
|
|
47558
|
+
this.extensions = extensions;
|
|
47559
|
+
return this.extensions;
|
|
47560
|
+
}
|
|
47561
|
+
replaceCustomMarkers(usfmString) {
|
|
47562
|
+
let modifiedUsfm = usfmString;
|
|
47563
|
+
for (const marker of Object.keys(this.extensions)){
|
|
47564
|
+
const category = this.extensions[marker].category;
|
|
47565
|
+
const markerType = $b0abb17ac2d74d5e$export$ca0f3793b4450a5d[category];
|
|
47566
|
+
if (markerType === undefined) continue;
|
|
47567
|
+
const replacement = $b0abb17ac2d74d5e$export$15add78feb2cf2fb[markerType];
|
|
47568
|
+
// Only char markers have a nested (\+marker) form in the grammar, so
|
|
47569
|
+
// only those may carry a + through to the prefixed tag
|
|
47570
|
+
const nestedPrefix = markerType === 'char' ? '\\+?' : '';
|
|
47571
|
+
const markerPattern = new RegExp(`\\\\(${nestedPrefix})${$b0abb17ac2d74d5e$var$escapeRegExp(marker)}(?=[^\\w-]|$)`, 'g');
|
|
47572
|
+
// A function replacement keeps `$` patterns in the marker name literal
|
|
47573
|
+
const replacementTag = `${replacement}${marker}`;
|
|
47574
|
+
modifiedUsfm = modifiedUsfm.replace(markerPattern, (match, plus)=>`\\${plus}${replacementTag}`);
|
|
47575
|
+
}
|
|
47576
|
+
return modifiedUsfm;
|
|
47577
|
+
}
|
|
47578
|
+
}
|
|
47579
|
+
var $b0abb17ac2d74d5e$export$2e2bcd8739ae039 = $b0abb17ac2d74d5e$export$a014771799102136;
|
|
47580
|
+
|
|
47581
|
+
|
|
47086
47582
|
class $236d01ba6f80be5e$export$db89aa78daab09ca {
|
|
47087
47583
|
static language = null;
|
|
47088
47584
|
static async init(grammarPath = 'node_modules/usfm-grammar/tree-sitter-usfm.wasm', parserPath = 'node_modules/usfm-grammar/tree-sitter.wasm') {
|
|
@@ -47093,10 +47589,11 @@ class $236d01ba6f80be5e$export$db89aa78daab09ca {
|
|
|
47093
47589
|
});
|
|
47094
47590
|
$236d01ba6f80be5e$export$db89aa78daab09ca.language = await (0, $dc2P8.Language).load(grammarPath);
|
|
47095
47591
|
}
|
|
47096
|
-
constructor(usfmString = null, fromUsj = null, fromUsx = null, fromBibleNlp = null, bookCode = null){
|
|
47592
|
+
constructor(usfmString = null, fromUsj = null, fromUsx = null, fromBibleNlp = null, bookCode = null, markersExt = null){
|
|
47097
47593
|
this.syntaxTree = null;
|
|
47098
47594
|
this.errors = [];
|
|
47099
47595
|
this.warnings = [];
|
|
47596
|
+
this.markerExtensions = null;
|
|
47100
47597
|
let inputsGiven = 0;
|
|
47101
47598
|
if (usfmString !== null) inputsGiven += 1;
|
|
47102
47599
|
if (fromUsj !== null) inputsGiven += 1;
|
|
@@ -47118,6 +47615,11 @@ Only one of USFM, USJ, USX or BibleNLP is supported in one object.`);
|
|
|
47118
47615
|
this.bibleNlp = fromBibleNlp;
|
|
47119
47616
|
this.usfm = this.convertBibleNLPtoUSFM(bookCode);
|
|
47120
47617
|
}
|
|
47618
|
+
if (markersExt !== null) {
|
|
47619
|
+
this.markerExtensions = new (0, $b0abb17ac2d74d5e$export$2e2bcd8739ae039)();
|
|
47620
|
+
this.markerExtensions.readToObject(markersExt);
|
|
47621
|
+
if (Object.keys(this.markerExtensions.extensions).length > 0) this.usfm = this.markerExtensions.replaceCustomMarkers(this.usfm);
|
|
47622
|
+
}
|
|
47121
47623
|
this.parser = null;
|
|
47122
47624
|
this.initializeParser();
|
|
47123
47625
|
this.parseUSFM();
|
|
@@ -47149,7 +47651,7 @@ Only one of USFM, USJ, USX or BibleNLP is supported in one object.`);
|
|
|
47149
47651
|
if (!(1 <= this.usx.nodeType && this.usx.nodeType <= 12)) throw new Error('Input must be an instance of xmldom Document or Element');
|
|
47150
47652
|
if (this.usx.tagName !== 'usx') {
|
|
47151
47653
|
if (!(this.usx.getElementsByTagName('usx').length === 1)) throw new Error(`Expects a <usx> node.
|
|
47152
|
-
Refer docs: https://docs.usfm.bible/usfm/3.1/syntax.html#_usx_usfm_xml`);
|
|
47654
|
+
Refer docs: https://docs.usfm.bible/usfm/3.1.2/syntax.html#_usx_usfm_xml`);
|
|
47153
47655
|
this.usx = this.usx.getElementsByTagName('usx')[0];
|
|
47154
47656
|
}
|
|
47155
47657
|
// assert(this.usx.childNodes[0].tagName === 'book', "<book> expected as first element in <usx>")
|
|
@@ -47194,11 +47696,31 @@ Refer docs: https://docs.usfm.bible/usfm/3.1/syntax.html#_usx_usfm_xml`);
|
|
|
47194
47696
|
return null;
|
|
47195
47697
|
}
|
|
47196
47698
|
checkforMissing(node) {
|
|
47197
|
-
|
|
47198
|
-
|
|
47199
|
-
|
|
47200
|
-
|
|
47699
|
+
const cursor = node.walk();
|
|
47700
|
+
do {
|
|
47701
|
+
const currentNode = cursor.currentNode;
|
|
47702
|
+
if (currentNode.isMissing) this.errors.push(`At ${currentNode.startPosition.row + 1}:${currentNode.startPosition.column}, Error: Missing ${currentNode.type}`);
|
|
47703
|
+
if (cursor.gotoFirstChild()) continue;
|
|
47704
|
+
while(!cursor.gotoNextSibling()){
|
|
47705
|
+
if (!cursor.gotoParent()) return;
|
|
47706
|
+
}
|
|
47707
|
+
}while (true);
|
|
47201
47708
|
}
|
|
47709
|
+
// checkforMissing(node) {
|
|
47710
|
+
// console.log('Checking for missing nodes in:', node.type, 'at');
|
|
47711
|
+
// console.log(node.children.map(nod => nod.type).join(', '));
|
|
47712
|
+
// for (const n of node.children) {
|
|
47713
|
+
// if (n.isMissing) {
|
|
47714
|
+
// console.log(`Missing node found: ${n.type} `);
|
|
47715
|
+
// this.errors.push(
|
|
47716
|
+
// `At ${n.startPosition.row + 1}:${
|
|
47717
|
+
// n.startPosition.column
|
|
47718
|
+
// }, Error: Missing ${n.type}`,
|
|
47719
|
+
// );
|
|
47720
|
+
// }
|
|
47721
|
+
// this.checkforMissing(n);
|
|
47722
|
+
// }
|
|
47723
|
+
// }
|
|
47202
47724
|
convertUSJToUSFM() {
|
|
47203
47725
|
const outputUSFM = new (0, $ce44dcc4919407eb$export$2e2bcd8739ae039)().usjToUsfm(this.usj); // Simulated conversion
|
|
47204
47726
|
return outputUSFM;
|
|
@@ -47254,6 +47776,8 @@ Use ignoreErrors = true, as third parameter of toUSJ(), to generate output despi
|
|
|
47254
47776
|
const usjGenerator = new (0, $1bdca1468aa54399$export$2e2bcd8739ae039)($236d01ba6f80be5e$export$db89aa78daab09ca.language, this.usfm);
|
|
47255
47777
|
usjGenerator.nodeToUSJ(this.syntaxTree, usjGenerator.jsonRootObj);
|
|
47256
47778
|
outputUSJ = usjGenerator.jsonRootObj;
|
|
47779
|
+
this.warnings.push(...usjGenerator.warnings);
|
|
47780
|
+
this.errors.push(...usjGenerator.errors);
|
|
47257
47781
|
} catch (err) {
|
|
47258
47782
|
let message = 'Unable to do the conversion.';
|
|
47259
47783
|
if (this.errors) {
|
|
@@ -47264,11 +47788,25 @@ Use ignoreErrors = true, as third parameter of toUSJ(), to generate output despi
|
|
|
47264
47788
|
error: message
|
|
47265
47789
|
};
|
|
47266
47790
|
}
|
|
47267
|
-
if (includeMarkers)
|
|
47268
|
-
|
|
47269
|
-
|
|
47270
|
-
|
|
47271
|
-
|
|
47791
|
+
if (includeMarkers) {
|
|
47792
|
+
// Copy first: Filter members are shared arrays, and must not be appended to
|
|
47793
|
+
const includeList = [
|
|
47794
|
+
...includeMarkers
|
|
47795
|
+
];
|
|
47796
|
+
if (includeList.includes('list-s') || includeList.includes('list-e')) includeList.push('list-s/e');
|
|
47797
|
+
outputUSJ = (0, $ab5c81e737a0c6a6$export$ec91da630f36d5ea).keepOnly(outputUSJ, [
|
|
47798
|
+
...includeList,
|
|
47799
|
+
'USJ'
|
|
47800
|
+
], combineTexts);
|
|
47801
|
+
}
|
|
47802
|
+
if (excludeMarkers) {
|
|
47803
|
+
// Copy first: Filter members are shared arrays, and must not be appended to
|
|
47804
|
+
const excludeList = [
|
|
47805
|
+
...excludeMarkers
|
|
47806
|
+
];
|
|
47807
|
+
if (excludeList.includes('list-s') || excludeList.includes('list-e')) excludeList.push('list-s/e');
|
|
47808
|
+
outputUSJ = (0, $ab5c81e737a0c6a6$export$ec91da630f36d5ea).remove(outputUSJ, excludeList, combineTexts);
|
|
47809
|
+
}
|
|
47272
47810
|
return outputUSJ;
|
|
47273
47811
|
}
|
|
47274
47812
|
toList(excludeMarkers = null, includeMarkers = null, ignoreErrors = false, combineTexts = true) {
|
|
@@ -47341,6 +47879,8 @@ Use ignoreErrors=true to generate output despite errors`);
|
|
|
47341
47879
|
usxGenerator.node2Usx(this.syntaxTree, usxGenerator.xmlRootNode);
|
|
47342
47880
|
// xmlContent = usxSerializer.serializeToString(usxGenerator.xmlRootNode);
|
|
47343
47881
|
xmlContent = usxGenerator.xmlRootNode;
|
|
47882
|
+
this.warnings.push(...usxGenerator.warnings);
|
|
47883
|
+
this.errors.push(...usxGenerator.errors);
|
|
47344
47884
|
} catch (exe) {
|
|
47345
47885
|
let message = 'Unable to do the conversion. ';
|
|
47346
47886
|
if (this.errors.length > 0) {
|