@helloao/tools 0.0.6 → 0.0.9

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 (104) hide show
  1. package/dist/cjs/generation/api.cjs +240 -0
  2. package/dist/cjs/generation/api.cjs.map +7 -0
  3. package/dist/cjs/generation/audio.cjs +83 -0
  4. package/dist/cjs/generation/audio.cjs.map +7 -0
  5. package/dist/cjs/generation/book-order.cjs +508 -0
  6. package/dist/cjs/generation/book-order.cjs.map +7 -0
  7. package/dist/cjs/generation/common-types.cjs +17 -0
  8. package/dist/cjs/generation/common-types.cjs.map +7 -0
  9. package/dist/cjs/generation/dataset.cjs +158 -0
  10. package/dist/cjs/generation/dataset.cjs.map +7 -0
  11. package/dist/cjs/generation/index.cjs +51 -0
  12. package/dist/cjs/generation/index.cjs.map +7 -0
  13. package/dist/cjs/index.cjs +45 -0
  14. package/dist/cjs/index.cjs.map +7 -0
  15. package/dist/cjs/parser/codex-parser.cjs +176 -0
  16. package/dist/cjs/parser/codex-parser.cjs.map +7 -0
  17. package/dist/cjs/parser/index.cjs +48 -0
  18. package/dist/cjs/parser/index.cjs.map +7 -0
  19. package/dist/cjs/parser/iterators.cjs +204 -0
  20. package/dist/cjs/parser/iterators.cjs.map +7 -0
  21. package/dist/cjs/parser/types.cjs +17 -0
  22. package/dist/cjs/parser/types.cjs.map +7 -0
  23. package/dist/cjs/parser/usfm-parser.cjs +791 -0
  24. package/dist/cjs/parser/usfm-parser.cjs.map +7 -0
  25. package/dist/cjs/parser/usx-parser.cjs +471 -0
  26. package/dist/cjs/parser/usx-parser.cjs.map +7 -0
  27. package/dist/cjs/utils.cjs +85 -0
  28. package/dist/cjs/utils.cjs.map +7 -0
  29. package/dist/esm/generation/api.js +198 -0
  30. package/dist/esm/generation/api.js.map +7 -0
  31. package/dist/esm/generation/audio.js +53 -0
  32. package/dist/esm/generation/audio.js.map +7 -0
  33. package/dist/esm/generation/book-order.js +478 -0
  34. package/dist/esm/generation/book-order.js.map +7 -0
  35. package/dist/esm/generation/common-types.js +2 -0
  36. package/dist/esm/generation/common-types.js.map +7 -0
  37. package/dist/esm/generation/dataset.js +132 -0
  38. package/dist/esm/generation/dataset.js.map +7 -0
  39. package/dist/esm/generation/index.js +8 -0
  40. package/dist/esm/generation/index.js.map +7 -0
  41. package/dist/esm/index.js +6 -0
  42. package/dist/esm/index.js.map +7 -0
  43. package/dist/esm/parser/codex-parser.js +144 -0
  44. package/dist/esm/parser/codex-parser.js.map +7 -0
  45. package/dist/esm/parser/index.js +8 -0
  46. package/dist/esm/parser/index.js.map +7 -0
  47. package/dist/esm/parser/iterators.js +152 -0
  48. package/dist/esm/parser/iterators.js.map +7 -0
  49. package/dist/esm/parser/types.js +2 -0
  50. package/dist/esm/parser/types.js.map +7 -0
  51. package/dist/esm/parser/usfm-parser.js +749 -0
  52. package/dist/esm/parser/usfm-parser.js.map +7 -0
  53. package/dist/esm/parser/usx-parser.js +447 -0
  54. package/dist/esm/parser/usx-parser.js.map +7 -0
  55. package/dist/esm/utils.js +51 -0
  56. package/dist/esm/utils.js.map +7 -0
  57. package/{generation → dist/types/generation}/api.d.ts +2 -2
  58. package/{generation → dist/types/generation}/audio.d.ts +1 -1
  59. package/{generation → dist/types/generation}/dataset.d.ts +1 -1
  60. package/dist/types/generation/index.d.ts +7 -0
  61. package/dist/types/index.d.ts +5 -0
  62. package/{parser → dist/types/parser}/codex-parser.d.ts +1 -1
  63. package/dist/types/parser/index.d.ts +7 -0
  64. package/{parser → dist/types/parser}/usfm-parser.d.ts +1 -1
  65. package/{parser → dist/types/parser}/usx-parser.d.ts +2 -2
  66. package/package.json +25 -3
  67. package/generation/api.js +0 -187
  68. package/generation/api.spec.d.ts +0 -2
  69. package/generation/api.spec.js +0 -620
  70. package/generation/audio.js +0 -60
  71. package/generation/audio.spec.d.ts +0 -2
  72. package/generation/audio.spec.js +0 -36
  73. package/generation/book-order.js +0 -494
  74. package/generation/book-order.spec.d.ts +0 -2
  75. package/generation/book-order.spec.js +0 -8
  76. package/generation/common-types.js +0 -2
  77. package/generation/dataset.js +0 -106
  78. package/generation/index.d.ts +0 -7
  79. package/generation/index.js +0 -38
  80. package/index.d.ts +0 -5
  81. package/index.js +0 -32
  82. package/parser/codex-parser.js +0 -160
  83. package/parser/codex-parser.spec.d.ts +0 -2
  84. package/parser/codex-parser.spec.js +0 -645
  85. package/parser/index.d.ts +0 -7
  86. package/parser/index.js +0 -35
  87. package/parser/iterators.js +0 -222
  88. package/parser/iterators.spec.d.ts +0 -2
  89. package/parser/iterators.spec.js +0 -174
  90. package/parser/types.js +0 -2
  91. package/parser/usfm-parser.js +0 -840
  92. package/parser/usfm-parser.spec.d.ts +0 -2
  93. package/parser/usfm-parser.spec.js +0 -1593
  94. package/parser/usx-parser.js +0 -486
  95. package/parser/usx-parser.spec.d.ts +0 -2
  96. package/parser/usx-parser.spec.js +0 -1260
  97. package/utils.js +0 -73
  98. package/utils.spec.d.ts +0 -2
  99. package/utils.spec.js +0 -42
  100. /package/{generation → dist/types/generation}/book-order.d.ts +0 -0
  101. /package/{generation → dist/types/generation}/common-types.d.ts +0 -0
  102. /package/{parser → dist/types/parser}/iterators.d.ts +0 -0
  103. /package/{parser → dist/types/parser}/types.d.ts +0 -0
  104. /package/{utils.d.ts → dist/types/utils.d.ts} +0 -0
@@ -1,1260 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const usx_parser_1 = require("./usx-parser");
7
- const linkedom_1 = require("linkedom");
8
- const mat_usx_1 = __importDefault(require("../../../bible/webp_usx/mat.usx"));
9
- const jhn_usx_1 = __importDefault(require("../../../bible/webp_usx/jhn.usx"));
10
- const _1sa_usx_1 = __importDefault(require("../../../bible/webp_usx/1sa.usx"));
11
- describe('USXParser', () => {
12
- let parser;
13
- beforeEach(() => {
14
- globalThis.DOMParser = linkedom_1.DOMParser; // window.DOMParser as any;
15
- globalThis.Element = linkedom_1.Element; // window.Element;
16
- globalThis.Node = linkedom_1.Node; // window.Node;
17
- parser = new usx_parser_1.USXParser(new linkedom_1.DOMParser());
18
- });
19
- describe('parse()', () => {
20
- it('should parse a simple USX file', () => {
21
- const usx = `
22
- <usx version="3.0">
23
- <book code="GEN" style="id">- Berean Study Bible</book>
24
- <para style="h">Genesis</para>
25
- <para style="toc2">Genesis</para>
26
- <para style="toc1">Genesis</para>
27
- <para style="mt1">Genesis</para>
28
- <chapter number="1" style="c" sid="GEN 1"/>
29
- <para style="s1">The Creation</para>
30
- <para style="r">(John 1:1–5; Hebrews 11:1–3)</para>
31
- <para style="m">
32
- <verse number="1" style="v" sid="GEN 1:1"/>
33
- <char style="w" strong="H8064">In</char>
34
- <char style="w" strong="H1254">the</char>
35
- <char style="w" strong="H7225">beginning</char>
36
- <char style="w" strong="H8064">God</char>
37
- <char style="w" strong="H1254">created</char>
38
- <char style="w" strong="H1254">the</char>
39
- <char style="w" strong="H8064">heavens</char>
40
- <char style="w" strong="H8064">and</char>
41
- <char style="w" strong="H1254">the</char>
42
- <char style="w" strong="H8064">earth</char>.
43
- <verse eid="GEN 1:1"/>
44
- </para>
45
- </usx>
46
- `;
47
- const tree = parser.parse(usx);
48
- expect(tree).toEqual({
49
- type: 'root',
50
- id: 'GEN',
51
- header: 'Genesis',
52
- title: 'Genesis',
53
- content: [
54
- {
55
- type: 'chapter',
56
- number: 1,
57
- content: [
58
- {
59
- type: 'heading',
60
- content: ['The Creation']
61
- },
62
- {
63
- type: 'verse',
64
- number: 1,
65
- content: [
66
- 'In the beginning God created the heavens and the earth.'
67
- ]
68
- },
69
- ],
70
- footnotes: [],
71
- }
72
- ]
73
- });
74
- });
75
- it('should parse line breaks', () => {
76
- const usx = `
77
- <usx version="3.0">
78
- <book code="GEN" style="id">- Berean Study Bible</book>
79
- <para style="h">Genesis</para>
80
- <para style="toc2">Genesis</para>
81
- <para style="toc1">Genesis</para>
82
- <para style="mt1">Genesis</para>
83
- <chapter number="1" style="c" sid="GEN 1"/>
84
- <para style="s1">The Creation</para>
85
- <para style="r">(John 1:1–5; Hebrews 11:1–3)</para>
86
- <para style="m">
87
- <verse number="1" style="v" sid="GEN 1:1"/>
88
- <char style="w" strong="H8064">In</char>
89
- <char style="w" strong="H1254">the</char>
90
- <char style="w" strong="H7225">beginning</char>
91
- <char style="w" strong="H8064">God</char>
92
- <char style="w" strong="H1254">created</char>
93
- <char style="w" strong="H1254">the</char>
94
- <char style="w" strong="H8064">heavens</char>
95
- <char style="w" strong="H8064">and</char>
96
- <char style="w" strong="H1254">the</char>
97
- <char style="w" strong="H8064">earth</char>.
98
- <verse eid="GEN 1:1"/>
99
- </para>
100
- <para style="b"/>
101
- <para style="m">
102
- <verse number="2" style="v" sid="GEN 1:2"/>
103
- <char style="w" strong="H1961">Now</char>
104
- <char style="w" strong="H6440">the</char>
105
- <char style="w" strong="H0776">earth</char>
106
- <char style="w" strong="H1961">was</char>
107
- <char style="w" strong="H8414">formless</char>
108
- <char style="w" strong="H6440">and</char>
109
- <char style="w" strong="H2638">void</char>,
110
- <char style="w" strong="H6440">and</char>
111
- <char style="w" strong="H2822">darkness</char>
112
- <char style="w" strong="H1961">was</char>
113
- <char style="w" strong="H5921">over</char>
114
- <char style="w" strong="H6440">the</char>
115
- <char style="w" strong="H6440">surface</char>
116
- <char style="w" strong="H6440">of</char>
117
- <char style="w" strong="H6440">the</char>
118
- <char style="w" strong="H8415">deep</char>.
119
- <char style="w" strong="H6440">And</char>
120
- <char style="w" strong="H6440">the</char>
121
- <char style="w" strong="H7307">Spirit</char>
122
- <char style="w" strong="H6440">of</char>
123
- <char style="w" strong="H0430">God</char>
124
- <char style="w" strong="H1961">was</char>
125
- <char style="w" strong="H7363">hovering</char>
126
- <char style="w" strong="H5921">over</char>
127
- <char style="w" strong="H6440">the</char>
128
- <char style="w" strong="H6440">surface</char>
129
- <char style="w" strong="H6440">of</char>
130
- <char style="w" strong="H6440">the</char>
131
- <char style="w" strong="H4325">waters</char>.
132
- <verse eid="GEN 1:2"/>
133
- </para>
134
- </usx>
135
- `;
136
- const tree = parser.parse(usx);
137
- expect(tree).toEqual({
138
- type: 'root',
139
- id: 'GEN',
140
- header: 'Genesis',
141
- title: 'Genesis',
142
- content: [
143
- {
144
- type: 'chapter',
145
- number: 1,
146
- content: [
147
- {
148
- type: 'heading',
149
- content: ['The Creation']
150
- },
151
- {
152
- type: 'verse',
153
- number: 1,
154
- content: [
155
- 'In the beginning God created the heavens and the earth.'
156
- ]
157
- },
158
- {
159
- type: 'line_break',
160
- },
161
- {
162
- type: 'verse',
163
- number: 2,
164
- content: [
165
- 'Now the earth was formless and void, and darkness was over the surface of the deep. And the Spirit of God was hovering over the surface of the waters.'
166
- ]
167
- }
168
- ],
169
- footnotes: [],
170
- }
171
- ]
172
- });
173
- });
174
- it('should combine major title headings', () => {
175
- const usx = `
176
- <usx version="3.0">
177
- <book code="GEN" style="id">- Berean Study Bible</book>
178
- <para style="h">Genesis</para>
179
- <para style="toc2">Genesis</para>
180
- <para style="toc1">Genesis</para>
181
- <para style="mt1">The</para>
182
- <para style="mt2">Title</para>
183
- <para style="mt3">of the Book</para>
184
- <chapter number="1" style="c" sid="GEN 1"/>
185
- <para style="s1">The Creation</para>
186
- <para style="r">(John 1:1–5; Hebrews 11:1–3)</para>
187
- <para style="m">
188
- <verse number="1" style="v" sid="GEN 1:1"/>
189
- <char style="w" strong="H8064">In</char>
190
- <char style="w" strong="H1254">the</char>
191
- <char style="w" strong="H7225">beginning</char>
192
- <char style="w" strong="H8064">God</char>
193
- <char style="w" strong="H1254">created</char>
194
- <char style="w" strong="H1254">the</char>
195
- <char style="w" strong="H8064">heavens</char>
196
- <char style="w" strong="H8064">and</char>
197
- <char style="w" strong="H1254">the</char>
198
- <char style="w" strong="H8064">earth</char>.
199
- <verse eid="GEN 1:1"/>
200
- </para>
201
- </usx>
202
- `;
203
- const tree = parser.parse(usx);
204
- expect(tree).toEqual({
205
- type: 'root',
206
- id: 'GEN',
207
- title: 'The Title of the Book',
208
- header: 'Genesis',
209
- content: [
210
- {
211
- type: 'chapter',
212
- number: 1,
213
- content: [
214
- {
215
- type: 'heading',
216
- content: ['The Creation']
217
- },
218
- {
219
- type: 'verse',
220
- number: 1,
221
- content: [
222
- 'In the beginning God created the heavens and the earth.'
223
- ]
224
- },
225
- ],
226
- footnotes: [],
227
- }
228
- ]
229
- });
230
- });
231
- it('should combine major title in the order they appear', () => {
232
- const usx = `
233
- <usx version="3.0">
234
- <book code="GEN" style="id">- Berean Study Bible</book>
235
- <para style="h">Genesis</para>
236
- <para style="toc2">Genesis</para>
237
- <para style="toc1">Genesis</para>
238
- <para style="mt3">The</para>
239
- <para style="mt2">Title</para>
240
- <para style="mt1">of the Book</para>
241
- <chapter number="1" style="c" sid="GEN 1"/>
242
- <para style="s1">The Creation</para>
243
- <para style="r">(John 1:1–5; Hebrews 11:1–3)</para>
244
- <para style="m">
245
- <verse number="1" style="v" sid="GEN 1:1"/>
246
- <char style="w" strong="H8064">In</char>
247
- <char style="w" strong="H1254">the</char>
248
- <char style="w" strong="H7225">beginning</char>
249
- <char style="w" strong="H8064">God</char>
250
- <char style="w" strong="H1254">created</char>
251
- <char style="w" strong="H1254">the</char>
252
- <char style="w" strong="H8064">heavens</char>
253
- <char style="w" strong="H8064">and</char>
254
- <char style="w" strong="H1254">the</char>
255
- <char style="w" strong="H8064">earth</char>.
256
- <verse eid="GEN 1:1"/>
257
- </para>
258
- </usx>
259
- `;
260
- const tree = parser.parse(usx);
261
- expect(tree).toEqual({
262
- type: 'root',
263
- id: 'GEN',
264
- title: 'The Title of the Book',
265
- header: 'Genesis',
266
- content: [
267
- {
268
- type: 'chapter',
269
- number: 1,
270
- content: [
271
- {
272
- type: 'heading',
273
- content: ['The Creation']
274
- },
275
- {
276
- type: 'verse',
277
- number: 1,
278
- content: [
279
- 'In the beginning God created the heavens and the earth.'
280
- ]
281
- },
282
- ],
283
- footnotes: [],
284
- }
285
- ]
286
- });
287
- });
288
- it('should support section headings outside of chapters', () => {
289
- const usx = `
290
- <usx version="3.0">
291
- <book code="GEN" style="id">- Berean Study Bible</book>
292
- <para style="h">Genesis</para>
293
- <para style="toc2">Genesis</para>
294
- <para style="toc1">Genesis</para>
295
- <para style="mt1">Genesis</para>
296
- <chapter number="1" style="c" sid="GEN 1"/>
297
- <para style="s1">The Creation</para>
298
- <para style="r">(John 1:1–5; Hebrews 11:1–3)</para>
299
- <para style="m">
300
- <verse number="1" style="v" sid="GEN 1:1"/>
301
- <char style="w" strong="H8064">In</char>
302
- <char style="w" strong="H1254">the</char>
303
- <char style="w" strong="H7225">beginning</char>
304
- <char style="w" strong="H8064">God</char>
305
- <char style="w" strong="H1254">created</char>
306
- <char style="w" strong="H1254">the</char>
307
- <char style="w" strong="H8064">heavens</char>
308
- <char style="w" strong="H8064">and</char>
309
- <char style="w" strong="H1254">the</char>
310
- <char style="w" strong="H8064">earth</char>.
311
- <verse eid="GEN 1:1"/>
312
- </para>
313
- <chapter eid="GEN 1"/>
314
- <para style="s2">The Second Section</para>
315
- </usx>
316
- `;
317
- const tree = parser.parse(usx);
318
- expect(tree).toEqual({
319
- type: 'root',
320
- id: 'GEN',
321
- header: 'Genesis',
322
- title: 'Genesis',
323
- content: [
324
- {
325
- type: 'chapter',
326
- number: 1,
327
- content: [
328
- {
329
- type: 'heading',
330
- content: ['The Creation']
331
- },
332
- {
333
- type: 'verse',
334
- number: 1,
335
- content: [
336
- 'In the beginning God created the heavens and the earth.'
337
- ]
338
- },
339
- ],
340
- footnotes: [],
341
- },
342
- {
343
- type: 'heading',
344
- content: ['The Second Section']
345
- }
346
- ]
347
- });
348
- });
349
- it('should support multiple chapters', () => {
350
- const usx = `
351
- <usx version="3.0">
352
- <book code="GEN" style="id">- Berean Study Bible</book>
353
- <para style="h">Genesis</para>
354
- <para style="toc2">Genesis</para>
355
- <para style="toc1">Genesis</para>
356
- <para style="mt1">Genesis</para>
357
- <chapter number="1" style="c" sid="GEN 1"/>
358
- <para style="s1">The Creation</para>
359
- <para style="r">(John 1:1–5; Hebrews 11:1–3)</para>
360
- <para style="m">
361
- <verse number="1" style="v" sid="GEN 1:1"/>
362
- <char style="w" strong="H8064">In</char>
363
- <char style="w" strong="H1254">the</char>
364
- <char style="w" strong="H7225">beginning</char>
365
- <char style="w" strong="H8064">God</char>
366
- <char style="w" strong="H1254">created</char>
367
- <char style="w" strong="H1254">the</char>
368
- <char style="w" strong="H8064">heavens</char>
369
- <char style="w" strong="H8064">and</char>
370
- <char style="w" strong="H1254">the</char>
371
- <char style="w" strong="H8064">earth</char>.
372
- <verse eid="GEN 1:1"/>
373
- </para>
374
- <chapter eid="GEN 1"/>
375
- <para style="s2">The Second Section</para>
376
- <chapter number="2" sid="GEN 2"/>
377
- <para style="s1">The Seventh Day</para>
378
- <para style="r">(Exodus 16:22–30; Hebrews 4:1–11)</para>
379
- <para style="m">
380
- <verse number="1" style="v" sid="GEN 2:1"/>
381
- <char style="w" strong="H3541">Thus</char>
382
- <char style="w" strong="H3605">the</char>
383
- <char style="w" strong="H8064">heavens</char>
384
- <char style="w" strong="H8064">and</char>
385
- <char style="w" strong="H3605">the</char>
386
- <char style="w" strong="H8064">earth</char>
387
- <char style="w" strong="H8064">were</char>
388
- <char style="w" strong="H3615">completed</char>
389
- <char style="w" strong="H6635">in</char>
390
- <char style="w" strong="H3605">all</char>
391
- <char style="w" strong="H3605">their</char>
392
- <char style="w" strong="H6635">vast</char>
393
- <char style="w" strong="H6635">array</char>.
394
- <verse eid="GEN 2:1"/>
395
- </para>
396
- </usx>
397
- `;
398
- const tree = parser.parse(usx);
399
- expect(tree).toEqual({
400
- type: 'root',
401
- id: 'GEN',
402
- header: 'Genesis',
403
- title: 'Genesis',
404
- content: [
405
- {
406
- type: 'chapter',
407
- number: 1,
408
- content: [
409
- {
410
- type: 'heading',
411
- content: ['The Creation']
412
- },
413
- {
414
- type: 'verse',
415
- number: 1,
416
- content: [
417
- 'In the beginning God created the heavens and the earth.'
418
- ]
419
- },
420
- ],
421
- footnotes: [],
422
- },
423
- {
424
- type: 'heading',
425
- content: ['The Second Section']
426
- },
427
- {
428
- type: 'chapter',
429
- number: 2,
430
- content: [
431
- {
432
- type: 'heading',
433
- content: ['The Seventh Day']
434
- },
435
- {
436
- type: 'verse',
437
- number: 1,
438
- content: [
439
- 'Thus the heavens and the earth were completed in all their vast array.'
440
- ]
441
- },
442
- ],
443
- footnotes: [],
444
- },
445
- ]
446
- });
447
- });
448
- it('should support footnotes', () => {
449
- const usx = `
450
- <usx version="3.0">
451
- <book code="GEN" style="id">- Berean Study Bible</book>
452
- <para style="h">Genesis</para>
453
- <para style="toc2">Genesis</para>
454
- <para style="toc1">Genesis</para>
455
- <para style="mt1">Genesis</para>
456
- <chapter number="2" style="c" sid="GEN 2"/>
457
- <para style="s1">The Seventh Day</para>
458
- <para style="r">(Exodus 16:22–30; Hebrews 4:1–11)</para>
459
- <para style="m">
460
- <verse number="1" style="v" sid="GEN 2:1"/>
461
- <char style="w" strong="H3541">Thus</char>
462
- <char style="w" strong="H3605">the</char>
463
- <char style="w" strong="H8064">heavens</char>
464
- <char style="w" strong="H8064">and</char>
465
- <char style="w" strong="H3605">the</char>
466
- <char style="w" strong="H8064">earth</char>
467
- <char style="w" strong="H8064">were</char>
468
- <char style="w" strong="H3615">completed</char>
469
- <char style="w" strong="H6635">in</char>
470
- <char style="w" strong="H3605">all</char>
471
- <char style="w" strong="H3605">their</char>
472
- <char style="w" strong="H6635">vast</char>
473
- <char style="w" strong="H6635">array</char>.
474
- <verse eid="GEN 2:1"/>
475
- <verse number="2" style="v" sid="GEN 2:2"/>
476
- <char style="w" strong="H3117">And</char>
477
- <char style="w" strong="H3117">by</char>
478
- <char style="w" strong="H3605">the</char>
479
- <char style="w" strong="H7637">seventh</char>
480
- <char style="w" strong="H3117">day</char>
481
- <char style="w" strong="H0430">God</char>
482
- <char style="w" strong="H3117">had</char>
483
- <char style="w" strong="H3615">finished</char>
484
- <char style="w" strong="H3605">the</char>
485
- <char style="w" strong="H4399">work</char>
486
- <char style="w" strong="H3117">He</char>
487
- <char style="w" strong="H3117">had</char>
488
- <char style="w" strong="H3615">been</char>
489
- <char style="w" strong="H6213">doing</char>;
490
- <char style="w" strong="H6213">so</char>
491
- <char style="w" strong="H3117">on</char>
492
- <char style="w" strong="H3605">that</char>
493
- <char style="w" strong="H3117">day</char>
494
- <char style="w" strong="H3117">He</char>
495
- <char style="w" strong="H7673">rested</char>
496
- <char style="w" strong="H3117">from</char>
497
- <char style="w" strong="H3605">all</char>
498
- <char style="w" strong="H3605">His</char>
499
- <char style="w" strong="H4399">work</char>.
500
- <note style="f" caller="+">
501
- <char style="fr"/>
502
- <char style="ft">2:2 </char>
503
- <char style="ft">Cited in Hebrews 4:4</char>
504
- </note>
505
- <verse eid="GEN 2:2"/>
506
- </para>
507
- </usx>
508
- `;
509
- const tree = parser.parse(usx);
510
- expect(tree).toEqual({
511
- type: 'root',
512
- id: 'GEN',
513
- header: 'Genesis',
514
- title: 'Genesis',
515
- content: [
516
- {
517
- type: 'chapter',
518
- number: 2,
519
- content: [
520
- {
521
- type: 'heading',
522
- content: ['The Seventh Day']
523
- },
524
- {
525
- type: 'verse',
526
- number: 1,
527
- content: [
528
- 'Thus the heavens and the earth were completed in all their vast array.'
529
- ]
530
- },
531
- {
532
- type: 'verse',
533
- number: 2,
534
- content: [
535
- 'And by the seventh day God had finished the work He had been doing; so on that day He rested from all His work.',
536
- {
537
- noteId: 0,
538
- }
539
- ]
540
- },
541
- ],
542
- footnotes: [
543
- {
544
- noteId: 0,
545
- caller: '+',
546
- text: 'Cited in Hebrews 4:4',
547
- reference: {
548
- chapter: 2,
549
- verse: 2,
550
- }
551
- }
552
- ],
553
- }
554
- ]
555
- });
556
- });
557
- it('should ignore introduction paragraphs', () => {
558
- const usx = `
559
- <usx version="3.0">
560
- <book code="GEN" style="id">- Berean Study Bible</book>
561
- <para style="h">Genesis</para>
562
- <para style="toc2">Genesis</para>
563
- <para style="toc1">Genesis</para>
564
- <para style="mt1">Genesis</para>
565
- <chapter number="2" style="c" sid="GEN 2"/>
566
- <para style="s1">The Seventh Day</para>
567
- <para style="r">(Exodus 16:22–30; Hebrews 4:1–11)</para>
568
- <para style="ip">This is an introduction paragraph.</para>
569
- <para style="m">
570
- <verse number="1" style="v" sid="GEN 2:1"/>
571
- <char style="w" strong="H3541">Thus</char>
572
- <char style="w" strong="H3605">the</char>
573
- <char style="w" strong="H8064">heavens</char>
574
- <char style="w" strong="H8064">and</char>
575
- <char style="w" strong="H3605">the</char>
576
- <char style="w" strong="H8064">earth</char>
577
- <char style="w" strong="H8064">were</char>
578
- <char style="w" strong="H3615">completed</char>
579
- <char style="w" strong="H6635">in</char>
580
- <char style="w" strong="H3605">all</char>
581
- <char style="w" strong="H3605">their</char>
582
- <char style="w" strong="H6635">vast</char>
583
- <char style="w" strong="H6635">array</char>.
584
- <verse eid="GEN 2:1"/>
585
- <verse number="2" style="v" sid="GEN 2:2"/>
586
- <char style="w" strong="H3117">And</char>
587
- <char style="w" strong="H3117">by</char>
588
- <char style="w" strong="H3605">the</char>
589
- <char style="w" strong="H7637">seventh</char>
590
- <char style="w" strong="H3117">day</char>
591
- <char style="w" strong="H0430">God</char>
592
- <char style="w" strong="H3117">had</char>
593
- <char style="w" strong="H3615">finished</char>
594
- <char style="w" strong="H3605">the</char>
595
- <char style="w" strong="H4399">work</char>
596
- <char style="w" strong="H3117">He</char>
597
- <char style="w" strong="H3117">had</char>
598
- <char style="w" strong="H3615">been</char>
599
- <char style="w" strong="H6213">doing</char>;
600
- <char style="w" strong="H6213">so</char>
601
- <char style="w" strong="H3117">on</char>
602
- <char style="w" strong="H3605">that</char>
603
- <char style="w" strong="H3117">day</char>
604
- <char style="w" strong="H3117">He</char>
605
- <char style="w" strong="H7673">rested</char>
606
- <char style="w" strong="H3117">from</char>
607
- <char style="w" strong="H3605">all</char>
608
- <char style="w" strong="H3605">His</char>
609
- <char style="w" strong="H4399">work</char>.
610
- <note style="f" caller="+">
611
- <char style="fr"/>
612
- <char style="ft">2:2 </char>
613
- <char style="ft">Cited in Hebrews 4:4</char>
614
- </note>
615
- <verse eid="GEN 2:2"/>
616
- </para>
617
- </usx>
618
- `;
619
- const tree = parser.parse(usx);
620
- expect(tree).toEqual({
621
- type: 'root',
622
- id: 'GEN',
623
- header: 'Genesis',
624
- title: 'Genesis',
625
- content: [
626
- {
627
- type: 'chapter',
628
- number: 2,
629
- content: [
630
- {
631
- type: 'heading',
632
- content: ['The Seventh Day']
633
- },
634
- {
635
- type: 'verse',
636
- number: 1,
637
- content: [
638
- 'Thus the heavens and the earth were completed in all their vast array.'
639
- ]
640
- },
641
- {
642
- type: 'verse',
643
- number: 2,
644
- content: [
645
- 'And by the seventh day God had finished the work He had been doing; so on that day He rested from all His work.',
646
- {
647
- noteId: 0,
648
- }
649
- ]
650
- },
651
- ],
652
- footnotes: [
653
- {
654
- noteId: 0,
655
- caller: '+',
656
- text: 'Cited in Hebrews 4:4',
657
- reference: {
658
- chapter: 2,
659
- verse: 2,
660
- }
661
- }
662
- ],
663
- }
664
- ]
665
- });
666
- });
667
- it('should suppport parsing descriptive titles', () => {
668
- const usx = `
669
- <usx version="3.0">
670
- <book code="PSA" style="id">- Berean Study Bible</book>
671
- <chapter number="6" style="c" sid="PSA 6"/>
672
- <para style="s1">Do Not Rebuke Me in Your Anger</para>
673
- <para style="r">(Psalms 38:1–22)</para>
674
- <para style="d">
675
- For the choirmaster. With stringed instruments, according to Sheminith.
676
- <note style="f" caller="+">
677
- <char style="fr"/>
678
- <char style="ft">6:0 </char>
679
- <char style="ft">Sheminith is probably a musical term; here and in 1 Chronicles 15:21 and Psalms 12:1.</char>
680
- </note>
681
- A Psalm of David.
682
- </para>
683
- <para style="b"/>
684
- <para style="q1">
685
- <verse number="1" style="v" sid="PSA 6:1"/>
686
- <char style="w" strong="H3069">O</char>
687
- <char style="w" strong="H3068">LORD</char>,
688
- <char style="w" strong="H6213">do</char>
689
- <char style="w" strong="H1732">not</char>
690
- <char style="w" strong="H1606">rebuke</char>
691
- <char style="w" strong="H5921">me</char>
692
- <char style="w" strong="H5921">in</char>
693
- <char style="w" strong="H5921">Your</char>
694
- <char style="w" strong="H0639">anger</char>
695
- </para>
696
- <para style="q2">
697
- <char style="w" strong="H0176">or</char>
698
- <char style="w" strong="H4148">discipline</char>
699
- <char style="w" strong="H5921">me</char>
700
- <char style="w" strong="H5921">in</char>
701
- <char style="w" strong="H5921">Your</char>
702
- <char style="w" strong="H2534">wrath</char>.
703
- <verse eid="PSA 6:1"/>
704
- </para>
705
- </usx>
706
- `;
707
- const tree = parser.parse(usx);
708
- expect(tree).toEqual({
709
- type: 'root',
710
- id: 'PSA',
711
- content: [
712
- {
713
- type: 'chapter',
714
- number: 6,
715
- content: [
716
- {
717
- type: 'heading',
718
- content: ['Do Not Rebuke Me in Your Anger']
719
- },
720
- {
721
- type: 'hebrew_subtitle',
722
- content: [
723
- 'For the choirmaster. With stringed instruments, according to Sheminith.',
724
- { noteId: 0 },
725
- 'A Psalm of David.'
726
- ]
727
- },
728
- {
729
- type: 'line_break',
730
- },
731
- {
732
- type: 'verse',
733
- number: 1,
734
- content: [
735
- { text: 'O LORD, do not rebuke me in Your anger', poem: 1 },
736
- { text: 'or discipline me in Your wrath.', poem: 2 },
737
- ]
738
- },
739
- ],
740
- footnotes: [
741
- {
742
- noteId: 0,
743
- text: 'Sheminith is probably a musical term; here and in 1 Chronicles 15:21 and Psalms 12:1.',
744
- caller: '+',
745
- reference: {
746
- chapter: 6,
747
- verse: 0
748
- }
749
- }
750
- ],
751
- }
752
- ]
753
- });
754
- });
755
- it('should suppport verses in descriptive titles', () => {
756
- const usx = `
757
- <usx version="3.0">
758
- <book code="ZEC" style="id">- Berean Study Bible</book>
759
- <chapter number="12" style="c" sid="ZEC 12"/>
760
- <para style="s1">The Coming Deliverance of Jerusalem</para>
761
- <para style="d"><verse number="1" style="v" sid="ZEC 12:1"/><char style="w" strong="H1697">This</char> <char style="w" strong="H3068">is</char> <char style="w" strong="H5002">the</char> <char style="w" strong="H4853">burden</char> <char style="w" strong="H3068">of</char> <char style="w" strong="H5002">the</char> <char style="w" strong="H1697">word</char> <char style="w" strong="H3068">of</char> <char style="w" strong="H5002">the</char> <char style="w" strong="H3068">LORD</char> <char style="w" strong="H5921">concerning</char> <char style="w" strong="H3478">Israel</char>.</para>
762
- <para style="b"/>
763
- <para style="m"><char style="w" strong="H1697">Thus</char> <char style="w" strong="H5002">declares</char> <char style="w" strong="H5002">the</char> <char style="w" strong="H3068">LORD</char>, <char style="w" strong="H3068">who</char> <char style="w" strong="H5186">stretches</char> <char style="w" strong="H5186">out</char> <char style="w" strong="H5002">the</char> <char style="w" strong="H8064">heavens</char> <char style="w" strong="H3478">and</char> <char style="w" strong="H3245">lays</char> <char style="w" strong="H5002">the</char> <char style="w" strong="H3245">foundation</char> <char style="w" strong="H3068">of</char> <char style="w" strong="H5002">the</char> <char style="w" strong="H8064">earth</char>, <char style="w" strong="H3068">who</char> <char style="w" strong="H3335">forms</char> <char style="w" strong="H5002">the</char> <char style="w" strong="H7307">spirit</char> <char style="w" strong="H3068">of</char> <char style="w" strong="H0376">man</char> <char style="w" strong="H7130">within</char> <char style="w" strong="H5921">him</char>:<verse eid="ZEC 12:1"/></para>
764
- </usx>
765
- `;
766
- const tree = parser.parse(usx);
767
- expect(tree).toEqual({
768
- type: 'root',
769
- id: 'ZEC',
770
- content: [
771
- {
772
- type: 'chapter',
773
- number: 12,
774
- content: [
775
- {
776
- type: 'heading',
777
- content: ['The Coming Deliverance of Jerusalem']
778
- },
779
- {
780
- type: 'verse',
781
- number: 1,
782
- content: [
783
- {
784
- text: 'This is the burden of the word of the LORD concerning Israel.',
785
- descriptive: true,
786
- },
787
- {
788
- lineBreak: true
789
- },
790
- 'Thus declares the LORD, who stretches out the heavens and lays the foundation of the earth, who forms the spirit of man within him:'
791
- ]
792
- },
793
- ],
794
- footnotes: [],
795
- }
796
- ]
797
- });
798
- });
799
- it('should ignore cross references', () => {
800
- const usx = `
801
- <usx version="3.0">
802
- <book code="MAT" style="id">- World English Bible</book>
803
- <chapter number="5" style="c" sid="MAT 5"/>
804
- <para style="q1">
805
- <verse number="3" style="v" sid="MAT 5:3"/>
806
- <char style="wj">
807
- “<char style="w" strong="G3107">Blessed</char>
808
- <char style="w" strong="G1510">are</char>
809
- <char style="w" strong="G3588">the</char>
810
- <char style="w" strong="G4434">poor</char>
811
- <char style="w" strong="G3588">in</char>
812
- <char style="w" strong="G4151">spirit</char>,
813
- </char>
814
- </para>
815
- <para style="q2">
816
- <char style="wj">
817
- <char style="w" strong="G3754">for</char>
818
- <char style="w" strong="G0846">theirs</char>
819
- <char style="w" strong="G1510">is</char>
820
- <char style="w" strong="G3588">the</char>
821
- <char style="w" strong="G0932">Kingdom</char>
822
- <char style="w" strong="G4151">of</char>
823
- <char style="w" strong="G3772">Heaven</char>.
824
- </char>
825
- <note style="x" caller="+">
826
- <char style="xo">5:3 </char>
827
- <char style="xt">Isaiah 57:15; 66:2</char>
828
- </note>
829
- <verse eid="MAT 5:3"/>
830
- </para>
831
- </usx>
832
- `;
833
- const tree = parser.parse(usx);
834
- expect(tree).toEqual({
835
- type: 'root',
836
- id: 'MAT',
837
- content: [
838
- {
839
- type: 'chapter',
840
- number: 5,
841
- content: [
842
- {
843
- type: 'verse',
844
- number: 3,
845
- content: [
846
- { text: '“Blessed are the poor in spirit,', poem: 1, wordsOfJesus: true, },
847
- { text: 'for theirs is the Kingdom of Heaven.', poem: 2, wordsOfJesus: true, },
848
- ]
849
- },
850
- ],
851
- footnotes: [],
852
- }
853
- ],
854
- });
855
- });
856
- it('should not ignore the node of a para element', () => {
857
- const usx = `
858
- <usx version="3.0">
859
- <book code="JHN" style="id">43-JHN-web.sfm World English Bible (WEB)</book>
860
- <chapter number="1" style="c" sid="JHN 1"/>
861
- <para style="p"><verse number="1" style="v" sid="JHN 1:1"/><char style="w" strong="G1722">In</char> <char style="w" strong="G1722">the</char> <char style="w" strong="G0746">beginning</char> <char style="w" strong="G1510">was</char> <char style="w" strong="G1722">the</char> <char style="w" strong="G3056">Word</char>, <char style="w" strong="G2532">and</char> <char style="w" strong="G1722">the</char> <char style="w" strong="G3056">Word</char> <char style="w" strong="G1510">was</char> <char style="w" strong="G1722">with</char> <char style="w" strong="G2316">God</char>, <char style="w" strong="G2532">and</char> <char style="w" strong="G1722">the</char> <char style="w" strong="G3056">Word</char> <char style="w" strong="G1510">was</char> <char style="w" strong="G2316">God</char>.<verse eid="JHN 1:1"/></para>
862
- </usx>
863
- `;
864
- const tree = parser.parse(usx);
865
- expect(tree).toEqual({
866
- type: 'root',
867
- id: 'JHN',
868
- content: [
869
- {
870
- type: 'chapter',
871
- number: 1,
872
- content: [
873
- {
874
- type: 'verse',
875
- number: 1,
876
- content: [
877
- 'In the beginning was the Word, and the Word was with God, and the Word was God.'
878
- ]
879
- },
880
- ],
881
- footnotes: [],
882
- }
883
- ]
884
- });
885
- });
886
- it('should not ignore newlines between two poem paras', () => {
887
- const usx = `
888
- <usx version="3.0">
889
- <book code="MAT" style="id">- World English Bible</book>
890
- <chapter number="2" style="c" sid="MAT 2"/>
891
- <para style="q2"><verse number="18" style="v" sid="MAT 2:18"/><char style="w" strong="G2532">she</char> wouldn&#8217;t <char style="w" strong="G1510">be</char> <char style="w" strong="G3870">comforted</char>,</para>
892
- <para style="q2"><char style="w" strong="G3754">because</char> <char style="w" strong="G2532">they</char> <char style="w" strong="G1510">are</char> <char style="w" strong="G3756">no</char> <char style="w" strong="G4183">more</char>.&#8221;<note style="x" caller="+"><char style="xo">2:18 </char><char style="xt">Jeremiah 31:15</char></note><verse eid="MAT 2:18"/></para>
893
- </usx>
894
- `;
895
- const tree = parser.parse(usx);
896
- expect(tree).toEqual({
897
- type: 'root',
898
- id: 'MAT',
899
- content: [
900
- {
901
- type: 'chapter',
902
- number: 2,
903
- content: [
904
- {
905
- type: 'verse',
906
- number: 18,
907
- content: [
908
- {
909
- text: 'she wouldn’t be comforted,',
910
- poem: 2,
911
- },
912
- {
913
- text: 'because they are no more.”',
914
- poem: 2,
915
- }
916
- ]
917
- },
918
- ],
919
- footnotes: [],
920
- }
921
- ]
922
- });
923
- });
924
- it('should support Words of Jesus', () => {
925
- const usx = `
926
- <usx version="3.0">
927
- <book code="MAT" style="id">- World English Bible</book>
928
- <chapter number="5" style="c" sid="MAT 5"/>
929
- <para style="q1">
930
- <verse number="3" style="v" sid="MAT 5:3"/>
931
- <char style="wj">
932
- “<char style="w" strong="G3107">Blessed</char>
933
- <char style="w" strong="G1510">are</char>
934
- <char style="w" strong="G3588">the</char>
935
- <char style="w" strong="G4434">poor</char>
936
- <char style="w" strong="G3588">in</char>
937
- <char style="w" strong="G4151">spirit</char>,
938
- </char>
939
- </para>
940
- <para style="q2">
941
- <char style="wj">
942
- <char style="w" strong="G3754">for</char>
943
- <char style="w" strong="G0846">theirs</char>
944
- <char style="w" strong="G1510">is</char>
945
- <char style="w" strong="G3588">the</char>
946
- <char style="w" strong="G0932">Kingdom</char>
947
- <char style="w" strong="G4151">of</char>
948
- <char style="w" strong="G3772">Heaven</char>.
949
- </char>
950
- <note style="x" caller="+">
951
- <char style="xo">5:3 </char>
952
- <char style="xt">Isaiah 57:15; 66:2</char>
953
- </note>
954
- <verse eid="MAT 5:3"/>
955
- </para>
956
- </usx>
957
- `;
958
- const tree = parser.parse(usx);
959
- expect(tree).toEqual({
960
- type: 'root',
961
- id: 'MAT',
962
- content: [
963
- {
964
- type: 'chapter',
965
- number: 5,
966
- content: [
967
- {
968
- type: 'verse',
969
- number: 3,
970
- content: [
971
- { text: '“Blessed are the poor in spirit,', poem: 1, wordsOfJesus: true, },
972
- { text: 'for theirs is the Kingdom of Heaven.', poem: 2, wordsOfJesus: true, },
973
- ]
974
- },
975
- ],
976
- footnotes: [],
977
- }
978
- ],
979
- });
980
- });
981
- it('should support verses that span multiple paragraphs', () => {
982
- const usx = `
983
- <usx version="3.0">
984
- <book code="GET" style="id">- BSB</book>
985
- <chapter number="26" style="c" sid="GEN 26"/>
986
- <para style="m"><verse number="8" style="v" sid="GEN 26:8"/><char style="w" strong="H3588">When</char> <char style="w" strong="H3327">Isaac</char> <char style="w" strong="H1961">had</char> <char style="w" strong="H1961">been</char> <char style="w" strong="H8033">there</char> <char style="w" strong="H1961">a</char> <char style="w" strong="H3117">long</char> <char style="w" strong="H3117">time</char>, <char style="w" strong="H0040">Abimelech</char> <char style="w" strong="H4428">king</char> <char style="w" strong="H4428">of</char> <char style="w" strong="H7200">the</char> <char style="w" strong="H6430">Philistines</char> <char style="w" strong="H7200">looked</char> <char style="w" strong="H8259">down</char> <char style="w" strong="H3117">from</char> <char style="w" strong="H7200">the</char> <char style="w" strong="H2474">window</char> <char style="w" strong="H4428">and</char> <char style="w" strong="H1961">was</char> <char style="w" strong="H8610">surprised</char> <char style="w" strong="H1961">to</char> <char style="w" strong="H7200">see</char> <char style="w" strong="H3327">Isaac</char> <char style="w" strong="H6711">caressing</char> <char style="w" strong="H7200">his</char> <char style="w" strong="H0802">wife</char> <char style="w" strong="H7259">Rebekah</char>.<verse eid="GEN 26:8"/> <verse number="9" style="v" sid="GEN 26:9"/><char style="w" strong="H0040">Abimelech</char> <char style="w" strong="H3327">sent</char> <char style="w" strong="H3588">for</char> <char style="w" strong="H3327">Isaac</char> <char style="w" strong="H3327">and</char> <char style="w" strong="H7121">said</char>, &#8220;<char style="w" strong="H6435">So</char> <char style="w" strong="H1931">she</char> <char style="w" strong="H1931">is</char> <char style="w" strong="H2088">really</char> <char style="w" strong="H5921">your</char> <char style="w" strong="H0802">wife</char>! <char style="w" strong="H3588">How</char> <char style="w" strong="H3201">could</char> <char style="w" strong="H3588">you</char> <char style="w" strong="H0559">say</char>, &#8216;<char style="w" strong="H1931">She</char> <char style="w" strong="H1931">is</char> <char style="w" strong="H5921">my</char> sister&#8217;?&#8221;</para>
987
- <para style="b"/>
988
- <para style="m"><char style="w" strong="H3327">Isaac</char> <char style="w" strong="H0559">replied</char>, &#8220;<char style="w" strong="H3588">Because</char> <char style="w" strong="H3588">I</char> <char style="w" strong="H0559">thought</char> <char style="w" strong="H3588">I</char> <char style="w" strong="H6435">might</char> <char style="w" strong="H4191">die</char> <char style="w" strong="H5921">on</char> <char style="w" strong="H5921">account</char> <char style="w" strong="H5921">of</char> <char style="w" strong="H5921">her</char>.&#8221;<verse eid="GEN 26:9"/></para>
989
- </usx>
990
- `;
991
- const tree = parser.parse(usx);
992
- expect(tree).toEqual({
993
- type: 'root',
994
- id: 'GET',
995
- content: [
996
- {
997
- type: 'chapter',
998
- number: 26,
999
- content: [
1000
- {
1001
- type: 'verse',
1002
- number: 8,
1003
- content: [
1004
- 'When Isaac had been there a long time, Abimelech king of the Philistines looked down from the window and was surprised to see Isaac caressing his wife Rebekah.'
1005
- ]
1006
- },
1007
- {
1008
- type: 'verse',
1009
- number: 9,
1010
- content: [
1011
- 'Abimelech sent for Isaac and said, “So she is really your wife! How could you say, ‘She is my sister’?”',
1012
- {
1013
- lineBreak: true,
1014
- },
1015
- 'Isaac replied, “Because I thought I might die on account of her.”'
1016
- ]
1017
- }
1018
- ],
1019
- footnotes: [],
1020
- }
1021
- ],
1022
- });
1023
- });
1024
- it('should support verses that are contained in the words of Jesus', () => {
1025
- const usx = `
1026
- <usx version="3.0">
1027
- <book code="MAT" style="id">- BSB</book>
1028
- <chapter number="17" style="c" sid="MAT 17"/>
1029
- <para style="p"><verse number="26" style="v" sid="MAT 17:26"/><char style="w" strong="G4074">Peter</char> <char style="w" strong="G3004">said</char> <char style="w" strong="G3004">to</char> <char style="w" strong="G3588">him</char>, &#8220;<char style="w" strong="G3588">From</char> <char style="w" strong="G3581">strangers</char>.&#8221;</para>
1030
- <para style="p"><char style="w" strong="G2424">Jesus</char> <char style="w" strong="G3004">said</char> <char style="w" strong="G3004">to</char> <char style="w" strong="G3588">him</char>, <char style="wj">&#8220;<char style="w" strong="G1161">Therefore</char> <char style="w" strong="G1161">the</char> <char style="w" strong="G5207">children</char> <char style="w" strong="G1510">are</char> <char style="w" strong="G1658">exempt</char>. </char><verse eid="MAT 17:26"/> <verse number="27" style="v" sid="MAT 17:27"/><char style="wj"><char style="w" strong="G1161">But</char>, <char style="w" strong="G3361">lest</char> <char style="w" strong="G2532">we</char> <char style="w" strong="G4624">cause</char> <char style="w" strong="G3588">them</char> <char style="w" strong="G1519">to</char> <char style="w" strong="G4624">stumble</char>, <char style="w" strong="G4198">go</char> <char style="w" strong="G1519">to</char> <char style="w" strong="G2532">the</char> <char style="w" strong="G2281">sea</char>, <char style="w" strong="G2532">cast</char> <char style="w" strong="G2532">a</char> <char style="w" strong="G0044">hook</char>, <char style="w" strong="G2532">and</char> <char style="w" strong="G2983">take</char> <char style="w" strong="G1519">up</char> <char style="w" strong="G2532">the</char> <char style="w" strong="G4413">first</char> <char style="w" strong="G2486">fish</char> <char style="w" strong="G2443">that</char> <char style="w" strong="G2532">comes</char> <char style="w" strong="G1519">up</char>. <char style="w" strong="G1161">When</char> <char style="w" strong="G4771">you</char> <char style="w" strong="G2532">have</char> <char style="w" strong="G0455">opened</char> <char style="w" strong="G1325">its</char> <char style="w" strong="G4750">mouth</char>, <char style="w" strong="G4771">you</char> <char style="w" strong="G2532">will</char> <char style="w" strong="G2147">find</char> <char style="w" strong="G2532">a</char> stater <char style="w" strong="G1406">coin</char>.</char><note style="f" caller="+"><char style="fr">17:27 </char><char style="ft">A stater is a silver coin equivalent to four Attic or two Alexandrian drachmas, or a Jewish shekel: just exactly enough to cover the half-shekel temple tax for two people. A shekel is about 10 grams or about 0.35 ounces, usually in the form of a silver coin.</char></note> <char style="wj"><char style="w" strong="G2983">Take</char> <char style="w" strong="G2443">that</char>, <char style="w" strong="G2532">and</char> <char style="w" strong="G1325">give</char> <char style="w" strong="G2532">it</char> <char style="w" strong="G1519">to</char> <char style="w" strong="G3588">them</char> <char style="w" strong="G1519">for</char> <char style="w" strong="G1325">me</char> <char style="w" strong="G2532">and</char> <char style="w" strong="G4771">you</char>.&#8221;</char><verse eid="MAT 17:27"/></para>
1031
- <chapter eid="MAT 17"/>
1032
- </usx>
1033
- `;
1034
- const tree = parser.parse(usx);
1035
- expect(tree).toEqual({
1036
- type: 'root',
1037
- id: 'MAT',
1038
- content: [
1039
- {
1040
- type: 'chapter',
1041
- number: 17,
1042
- content: [
1043
- {
1044
- type: 'verse',
1045
- number: 26,
1046
- content: [
1047
- 'Peter said to him, “From strangers.” Jesus said to him,',
1048
- {
1049
- wordsOfJesus: true,
1050
- text: '“Therefore the children are exempt.',
1051
- }
1052
- ]
1053
- },
1054
- {
1055
- type: 'verse',
1056
- number: 27,
1057
- content: [
1058
- {
1059
- wordsOfJesus: true,
1060
- text: 'But, lest we cause them to stumble, go to the sea, cast a hook, and take up the first fish that comes up. When you have opened its mouth, you will find a stater coin.'
1061
- },
1062
- {
1063
- noteId: 0,
1064
- },
1065
- {
1066
- wordsOfJesus: true,
1067
- text: 'Take that, and give it to them for me and you.”'
1068
- }
1069
- ]
1070
- }
1071
- ],
1072
- footnotes: [
1073
- {
1074
- noteId: 0,
1075
- caller: '+',
1076
- reference: {
1077
- chapter: 17,
1078
- verse: 27,
1079
- },
1080
- text: 'A stater is a silver coin equivalent to four Attic or two Alexandrian drachmas, or a Jewish shekel: just exactly enough to cover the half-shekel temple tax for two people. A shekel is about 10 grams or about 0.35 ounces, usually in the form of a silver coin.'
1081
- }
1082
- ],
1083
- }
1084
- ]
1085
- });
1086
- });
1087
- it('should support multiple verses within a paragraph', () => {
1088
- const usx = `
1089
- <usx>
1090
- <book code="ZEC" style="id">- BSB</book>
1091
- <chapter number="12" style="c" sid="ZEC 17"/>
1092
- <para style="b"/>
1093
- <para style="m"><verse number="10" style="v" sid="ZEC 12:10"/><char style="w" strong="H1732">Then</char> <char style="w" strong="H5921">I</char> <char style="w" strong="H1004">will</char> <char style="w" strong="H8210">pour</char> <char style="w" strong="H8210">out</char> <char style="w" strong="H5921">on</char> <char style="w" strong="H5921">the</char> <char style="w" strong="H1004">house</char> <char style="w" strong="H1004">of</char> <char style="w" strong="H1732">David</char> <char style="w" strong="H1004">and</char> <char style="w" strong="H5921">on</char> <char style="w" strong="H5921">the</char> <char style="w" strong="H3427">people</char> <char style="w" strong="H1004">of</char> <char style="w" strong="H3389">Jerusalem</char> <char style="w" strong="H5921">a</char> <char style="w" strong="H7307">spirit</char> <note style="f" caller="+"><char style="fr"/><char style="ft">12:10 </char><char style="ft">Or the Spirit</char></note> <char style="w" strong="H1004">of</char> <char style="w" strong="H2580">grace</char> <char style="w" strong="H1004">and</char> <char style="w" strong="H8605">prayer</char>, <char style="w" strong="H1004">and</char> <char style="w" strong="H5921">they</char> <char style="w" strong="H1004">will</char> <char style="w" strong="H5027">look</char> <char style="w" strong="H5921">on</char> <char style="w" strong="H5921">Me</char>,<note style="f" caller="+"><char style="fr"/><char style="ft">12:10 </char><char style="ft">Or to Me</char></note> <char style="w" strong="H5921">the</char> <char style="w" strong="H3173">One</char> <char style="w" strong="H5921">they</char> <char style="w" strong="H1004">have</char> <char style="w" strong="H1856">pierced</char>.<note style="f" caller="+"><char style="fr"/><char style="ft">12:10 </char><char style="ft">Cited in John 19:37</char></note> <char style="w" strong="H5921">They</char> <char style="w" strong="H1004">will</char> <char style="w" strong="H5594">mourn</char> <char style="w" strong="H5921">for</char> <char style="w" strong="H5921">Him</char> <char style="w" strong="H3389">as</char> <char style="w" strong="H3173">one</char> <char style="w" strong="H5594">mourns</char> <char style="w" strong="H5921">for</char> <char style="w" strong="H7307">an</char> <char style="w" strong="H3173">only</char> <char style="w" strong="H3173">child</char>, <char style="w" strong="H1004">and</char> <char style="w" strong="H6087">grieve</char> <char style="w" strong="H4843">bitterly</char> <char style="w" strong="H5921">for</char> <char style="w" strong="H5921">Him</char> <char style="w" strong="H3389">as</char> <char style="w" strong="H3173">one</char> grieves <char style="w" strong="H5921">for</char> <char style="w" strong="H5921">a</char> <char style="w" strong="H1060">firstborn</char> <char style="w" strong="H3173">son</char>.<verse eid="ZEC 12:10"/></para>
1094
- <para style="b"/>
1095
- <para style="m"><verse number="11" style="v" sid="ZEC 12:11"/><char style="w" strong="H3117">On</char> <char style="w" strong="H3117">that</char> <char style="w" strong="H3117">day</char> <char style="w" strong="H3117">the</char> <char style="w" strong="H4553">wailing</char> <char style="w" strong="H3117">in</char> <char style="w" strong="H3389">Jerusalem</char> <char style="w" strong="H3389">will</char> <char style="w" strong="H3117">be</char> <char style="w" strong="H3117">as</char> <char style="w" strong="H1431">great</char> <char style="w" strong="H3117">as</char> <char style="w" strong="H3117">the</char> <char style="w" strong="H4553">wailing</char> <char style="w" strong="H3117">of</char> Hadad-rimmon <char style="w" strong="H3117">in</char> <char style="w" strong="H3117">the</char> <char style="w" strong="H1237">plain</char> <char style="w" strong="H3117">of</char> <char style="w" strong="H4023">Megiddo</char>.<verse eid="ZEC 12:11"/> <verse number="12" style="v" sid="ZEC 12:12"/><char style="w" strong="H1732">The</char> <char style="w" strong="H4940">land</char> <char style="w" strong="H1004">will</char> <char style="w" strong="H5594">mourn</char>, <char style="w" strong="H0376">each</char> <char style="w" strong="H4940">clan</char> <char style="w" strong="H1004">on</char> <char style="w" strong="H3605">its</char> <char style="w" strong="H1961">own</char>: <char style="w" strong="H1732">the</char> <char style="w" strong="H4940">clan</char> <char style="w" strong="H1004">of</char> <char style="w" strong="H1732">the</char> <char style="w" strong="H1004">house</char> <char style="w" strong="H1004">of</char> <char style="w" strong="H1732">David</char> <char style="w" strong="H1004">and</char> <char style="w" strong="H1732">their</char> <char style="w" strong="H0802">wives</char>, <char style="w" strong="H1732">the</char> <char style="w" strong="H4940">clan</char> <char style="w" strong="H1004">of</char> <char style="w" strong="H1732">the</char> <char style="w" strong="H1004">house</char> <char style="w" strong="H1004">of</char> <char style="w" strong="H5416">Nathan</char> <char style="w" strong="H1004">and</char> <char style="w" strong="H1732">their</char> <char style="w" strong="H0802">wives</char>,<verse eid="ZEC 12:12"/> <verse number="13" style="v" sid="ZEC 12:13"/><char style="w" strong="H1004">the</char> <char style="w" strong="H4940">clan</char> <char style="w" strong="H1004">of</char> <char style="w" strong="H1004">the</char> <char style="w" strong="H1004">house</char> <char style="w" strong="H1004">of</char> <char style="w" strong="H3878">Levi</char> <char style="w" strong="H1004">and</char> <char style="w" strong="H3605">their</char> <char style="w" strong="H0802">wives</char>, <char style="w" strong="H1004">the</char> <char style="w" strong="H4940">clan</char> <char style="w" strong="H1004">of</char> <char style="w" strong="H8097">Shimei</char> <char style="w" strong="H1004">and</char> <char style="w" strong="H3605">their</char> <char style="w" strong="H0802">wives</char>,<verse eid="ZEC 12:13"/> <verse number="14" style="v" sid="ZEC 12:14"/><char style="w" strong="H3605">and</char> <char style="w" strong="H3605">all</char> <char style="w" strong="H3605">the</char> <char style="w" strong="H7604">remaining</char> <char style="w" strong="H4940">clans</char> <char style="w" strong="H3605">and</char> <char style="w" strong="H3605">their</char> <char style="w" strong="H0802">wives</char>.<verse eid="ZEC 12:14"/></para>
1096
- <chapter eid="ZEC 12"/>
1097
- </usx>
1098
- `;
1099
- const tree = parser.parse(usx);
1100
- expect(tree).toEqual({
1101
- type: 'root',
1102
- id: 'ZEC',
1103
- content: [
1104
- {
1105
- type: 'chapter',
1106
- number: 12,
1107
- content: [
1108
- {
1109
- type: 'line_break'
1110
- },
1111
- {
1112
- type: 'verse',
1113
- number: 10,
1114
- content: [
1115
- 'Then I will pour out on the house of David and on the people of Jerusalem a spirit',
1116
- {
1117
- noteId: 0
1118
- },
1119
- 'of grace and prayer, and they will look on Me,',
1120
- {
1121
- noteId: 1,
1122
- },
1123
- 'the One they have pierced.',
1124
- {
1125
- noteId: 2
1126
- },
1127
- 'They will mourn for Him as one mourns for an only child, and grieve bitterly for Him as one grieves for a firstborn son.'
1128
- ]
1129
- },
1130
- {
1131
- type: 'line_break'
1132
- },
1133
- {
1134
- type: 'verse',
1135
- number: 11,
1136
- content: [
1137
- 'On that day the wailing in Jerusalem will be as great as the wailing of Hadad-rimmon in the plain of Megiddo.',
1138
- ]
1139
- },
1140
- {
1141
- type: 'verse',
1142
- number: 12,
1143
- content: [
1144
- 'The land will mourn, each clan on its own: the clan of the house of David and their wives, the clan of the house of Nathan and their wives,',
1145
- ]
1146
- },
1147
- {
1148
- type: 'verse',
1149
- number: 13,
1150
- content: [
1151
- 'the clan of the house of Levi and their wives, the clan of Shimei and their wives,',
1152
- ]
1153
- },
1154
- {
1155
- type: 'verse',
1156
- number: 14,
1157
- content: [
1158
- 'and all the remaining clans and their wives.'
1159
- ]
1160
- }
1161
- ],
1162
- "footnotes": [
1163
- {
1164
- "caller": "+",
1165
- "noteId": 0,
1166
- "reference": {
1167
- "chapter": 12,
1168
- "verse": 10,
1169
- },
1170
- "text": "Or the Spirit",
1171
- },
1172
- {
1173
- "caller": "+",
1174
- "noteId": 1,
1175
- "reference": {
1176
- "chapter": 12,
1177
- "verse": 10,
1178
- },
1179
- "text": "Or to Me",
1180
- },
1181
- {
1182
- "caller": "+",
1183
- "noteId": 2,
1184
- "reference": {
1185
- "chapter": 12,
1186
- "verse": 10,
1187
- },
1188
- "text": "Cited in John 19:37",
1189
- },
1190
- ]
1191
- }
1192
- ]
1193
- });
1194
- });
1195
- it('should be able to parse a whole book', () => {
1196
- const tree = parser.parse(mat_usx_1.default);
1197
- expect(tree).toMatchSnapshot();
1198
- });
1199
- it('should be able to parse John', () => {
1200
- const tree = parser.parse(jhn_usx_1.default);
1201
- expect(tree).toMatchSnapshot();
1202
- });
1203
- it('should be able to parse 1SA', () => {
1204
- const tree = parser.parse(_1sa_usx_1.default);
1205
- expect(tree).toMatchSnapshot();
1206
- });
1207
- it('should not ignore the first word of a verse', () => {
1208
- const usx = firstXLines(jhn_usx_1.default, 38) + '\n</usx>';
1209
- const tree = parser.parse(usx);
1210
- expect(tree).toMatchSnapshot();
1211
- });
1212
- it('should not ignore the first word of continuation on a verse', () => {
1213
- const usx = `
1214
- <usx version="3.0">
1215
- <book code="MAT" style="id">- World English Bible</book>
1216
- <chapter number="1" style="c" sid="MAT 1"/>
1217
- <para style="q1"><verse number="23" style="v" sid="MAT 1:23"/>&#8220;<char style="w" strong="G2400">Behold</char>, <char style="w" strong="G1722">the</char> <char style="w" strong="G3933">virgin</char> <char style="w" strong="G2532">shall</char> <char style="w" strong="G1510">be</char> <char style="w" strong="G3326">with</char> <char style="w" strong="G1064">child</char>,</para>
1218
- <para style="q2"><char style="w" strong="G2532">and</char> <char style="w" strong="G2532">shall</char> <char style="w" strong="G5088">give</char> <char style="w" strong="G5088">birth</char> <char style="w" strong="G2532">to</char> <char style="w" strong="G2192">a</char> <char style="w" strong="G5207">son</char>.</para>
1219
- </usx>`;
1220
- const tree = parser.parse(usx);
1221
- expect(tree).toEqual({
1222
- type: 'root',
1223
- id: 'MAT',
1224
- content: [
1225
- {
1226
- type: 'chapter',
1227
- number: 1,
1228
- content: [
1229
- {
1230
- type: 'verse',
1231
- number: 23,
1232
- content: [
1233
- {
1234
- text: '“Behold, the virgin shall be with child,',
1235
- poem: 1,
1236
- },
1237
- {
1238
- text: 'and shall give birth to a son.',
1239
- poem: 2,
1240
- }
1241
- ]
1242
- },
1243
- ],
1244
- footnotes: [],
1245
- }
1246
- ],
1247
- });
1248
- });
1249
- // it('should parse the same as the USFM parser', () => {
1250
- // const usfmParser = new UsfmParser();
1251
- // const tree = parser.parse(Matthew);
1252
- // const usfmTree = usfmParser.parse(MatthewUsfm);
1253
- // expect(tree).toEqual(usfmTree);
1254
- // })
1255
- });
1256
- });
1257
- function firstXLines(content, x) {
1258
- const lines = content.split('\n');
1259
- return lines.slice(0, x).join('\n');
1260
- }