@helloao/tools 0.1.0 → 0.3.0

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 (78) hide show
  1. package/dist/cjs/generation/api.cjs +1580 -35
  2. package/dist/cjs/generation/api.cjs.map +3 -3
  3. package/dist/cjs/generation/audio.cjs +55 -8
  4. package/dist/cjs/generation/audio.cjs.map +2 -2
  5. package/dist/cjs/generation/book-order.cjs +1 -1
  6. package/dist/cjs/generation/book-order.cjs.map +2 -2
  7. package/dist/cjs/generation/common-types.cjs +996 -0
  8. package/dist/cjs/generation/common-types.cjs.map +2 -2
  9. package/dist/cjs/generation/dataset.cjs +44 -17
  10. package/dist/cjs/generation/dataset.cjs.map +2 -2
  11. package/dist/cjs/generation/index.cjs +8 -5
  12. package/dist/cjs/generation/index.cjs.map +2 -2
  13. package/dist/cjs/generation/simple.cjs +294 -0
  14. package/dist/cjs/generation/simple.cjs.map +7 -0
  15. package/dist/cjs/index.cjs +4 -4
  16. package/dist/cjs/parser/codex-parser.cjs +3 -3
  17. package/dist/cjs/parser/codex-parser.cjs.map +3 -3
  18. package/dist/cjs/parser/commentary-csv-parser.cjs +14 -3
  19. package/dist/cjs/parser/commentary-csv-parser.cjs.map +3 -3
  20. package/dist/cjs/parser/index.cjs +1 -1
  21. package/dist/cjs/parser/lockman-parser.cjs +334 -0
  22. package/dist/cjs/parser/lockman-parser.cjs.map +7 -0
  23. package/dist/cjs/parser/tyndale-xml-parser.cjs +1 -1
  24. package/dist/cjs/parser/tyndale-xml-parser.cjs.map +1 -1
  25. package/dist/cjs/parser/types.cjs.map +1 -1
  26. package/dist/cjs/parser/usfm-parser.cjs +2 -2
  27. package/dist/cjs/parser/usfm-parser.cjs.map +1 -1
  28. package/dist/cjs/parser/usx-parser.cjs +145 -32
  29. package/dist/cjs/parser/usx-parser.cjs.map +2 -2
  30. package/dist/cjs/parser/words.cjs +187 -0
  31. package/dist/cjs/parser/words.cjs.map +7 -0
  32. package/dist/cjs/utils.cjs +152 -0
  33. package/dist/cjs/utils.cjs.map +3 -3
  34. package/dist/esm/generation/api.js +1527 -35
  35. package/dist/esm/generation/api.js.map +3 -3
  36. package/dist/esm/generation/audio.js +47 -4
  37. package/dist/esm/generation/audio.js.map +2 -2
  38. package/dist/esm/generation/book-order.js +1 -1
  39. package/dist/esm/generation/book-order.js.map +2 -2
  40. package/dist/esm/generation/common-types.js +903 -0
  41. package/dist/esm/generation/common-types.js.map +3 -3
  42. package/dist/esm/generation/dataset.js +35 -10
  43. package/dist/esm/generation/dataset.js.map +2 -2
  44. package/dist/esm/generation/index.js +2 -1
  45. package/dist/esm/generation/index.js.map +2 -2
  46. package/dist/esm/generation/simple.js +260 -0
  47. package/dist/esm/generation/simple.js.map +7 -0
  48. package/dist/esm/parser/codex-parser.js +3 -3
  49. package/dist/esm/parser/codex-parser.js.map +3 -3
  50. package/dist/esm/parser/commentary-csv-parser.js +3 -2
  51. package/dist/esm/parser/commentary-csv-parser.js.map +2 -2
  52. package/dist/esm/parser/lockman-parser.js +306 -0
  53. package/dist/esm/parser/lockman-parser.js.map +7 -0
  54. package/dist/esm/parser/tyndale-xml-parser.js +1 -1
  55. package/dist/esm/parser/tyndale-xml-parser.js.map +1 -1
  56. package/dist/esm/parser/usfm-parser.js +1 -1
  57. package/dist/esm/parser/usfm-parser.js.map +1 -1
  58. package/dist/esm/parser/usx-parser.js +153 -32
  59. package/dist/esm/parser/usx-parser.js.map +2 -2
  60. package/dist/esm/parser/words.js +149 -0
  61. package/dist/esm/parser/words.js.map +7 -0
  62. package/dist/esm/utils.js +138 -0
  63. package/dist/esm/utils.js.map +2 -2
  64. package/dist/types/generation/api.d.ts +8478 -472
  65. package/dist/types/generation/audio.d.ts +5 -0
  66. package/dist/types/generation/common-types.d.ts +1646 -407
  67. package/dist/types/generation/dataset.d.ts +1 -0
  68. package/dist/types/generation/index.d.ts +2 -1
  69. package/dist/types/generation/simple.d.ts +110 -0
  70. package/dist/types/parser/codex-parser.d.ts +18 -138
  71. package/dist/types/parser/commentary-csv-parser.d.ts +1 -1
  72. package/dist/types/parser/lockman-parser.d.ts +14 -0
  73. package/dist/types/parser/tyndale-xml-parser.d.ts +1 -1
  74. package/dist/types/parser/types.d.ts +67 -0
  75. package/dist/types/parser/usx-parser.d.ts +6 -5
  76. package/dist/types/parser/words.d.ts +104 -0
  77. package/dist/types/utils.d.ts +223 -18
  78. package/package.json +7 -4
@@ -0,0 +1,334 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var lockman_parser_exports = {};
20
+ __export(lockman_parser_exports, {
21
+ LOCKMAN_PARSER_VERSION: () => LOCKMAN_PARSER_VERSION,
22
+ LockmanParser: () => LockmanParser
23
+ });
24
+ module.exports = __toCommonJS(lockman_parser_exports);
25
+ var import_book_order = require("../generation/book-order.js");
26
+ const LOCKMAN_PARSER_VERSION = 3;
27
+ const bookNumberIdMap = /* @__PURE__ */ new Map();
28
+ for (const [id, order] of import_book_order.bookOrderMap) {
29
+ if (!bookNumberIdMap.has(order)) {
30
+ bookNumberIdMap.set(order, id);
31
+ }
32
+ }
33
+ class LockmanParser {
34
+ parse(text) {
35
+ const roots = [];
36
+ let currentRoot = null;
37
+ let currentChapter = null;
38
+ let currentVerse = null;
39
+ const structureRegex = /(<BN>.*?<\/BN>)|((?:<CN>.*?<\/CN>)|(?:<SN>.*?<\/SN>))|((?:<SH>.*?<\/SH>)|(?:<SS>.*?<\/SS>))|((?:<V>|<C>|<CC>|<CP>|<PM>|<A>|<PO>|<P>|<PN>)\{\{.*?\}\}\d+(?:<T>|\^)(?:\{.*?\})?)/g;
40
+ let lastIndex = 0;
41
+ let match;
42
+ let isPoem = false;
43
+ while ((match = structureRegex.exec(text)) !== null) {
44
+ const fullMatch = match[0];
45
+ const startIndex = match.index;
46
+ if (startIndex > lastIndex) {
47
+ const content = text.substring(lastIndex, startIndex);
48
+ if (currentVerse && currentChapter) {
49
+ this.parseVerseContent(
50
+ content,
51
+ currentVerse,
52
+ currentChapter,
53
+ isPoem
54
+ );
55
+ }
56
+ }
57
+ lastIndex = startIndex + fullMatch.length;
58
+ if (match[1]) {
59
+ const title = match[1].replace(/<\/?BN>/g, "").trim();
60
+ currentRoot = {
61
+ type: "root",
62
+ title,
63
+ content: []
64
+ };
65
+ roots.push(currentRoot);
66
+ currentChapter = null;
67
+ currentVerse = null;
68
+ } else if (match[2]) {
69
+ if (!currentRoot) {
70
+ currentRoot = {
71
+ type: "root",
72
+ content: []
73
+ };
74
+ roots.push(currentRoot);
75
+ }
76
+ const inner = match[2].replace(/<\/?(CN|SN)>/g, "").trim();
77
+ const numMatch = inner.match(/\d+/);
78
+ const num = numMatch ? parseInt(numMatch[0], 10) : 0;
79
+ currentChapter = {
80
+ type: "chapter",
81
+ number: num,
82
+ content: [],
83
+ footnotes: []
84
+ };
85
+ currentRoot.content.push(currentChapter);
86
+ currentVerse = null;
87
+ } else if (match[3]) {
88
+ if (!currentRoot) {
89
+ currentRoot = { type: "root", content: [] };
90
+ roots.push(currentRoot);
91
+ }
92
+ const raw = match[3];
93
+ if (raw.startsWith("<SS>")) {
94
+ const inner = raw.replace(/<\/?SS>/g, "").trim();
95
+ const subtitle = {
96
+ type: "hebrew_subtitle",
97
+ content: []
98
+ };
99
+ if (currentChapter) {
100
+ this.parseHebrewSubtitleContent(
101
+ inner,
102
+ subtitle,
103
+ currentChapter
104
+ );
105
+ currentChapter.content.push(subtitle);
106
+ }
107
+ } else {
108
+ const inner = raw.replace(/<\/?SH>/g, "").trim();
109
+ const normalized = inner.replace(/<\\>|<\/?>|[{}]/g, "");
110
+ const heading = {
111
+ type: "heading",
112
+ content: [normalized]
113
+ };
114
+ if (currentChapter) {
115
+ currentChapter.content.push(heading);
116
+ } else {
117
+ currentRoot.content.push(heading);
118
+ }
119
+ }
120
+ } else if (match[4]) {
121
+ const tagContent = match[4];
122
+ if (currentRoot && !currentRoot.id) {
123
+ const bookId = this.getBookIdFromVerseTag(tagContent);
124
+ if (bookId) {
125
+ currentRoot.id = bookId;
126
+ }
127
+ }
128
+ const vNumMatch = tagContent.match(/(\d+)(?:<T>|\^)/);
129
+ const vNum = vNumMatch ? parseInt(vNumMatch[1], 10) : 0;
130
+ if (currentChapter) {
131
+ if (tagContent.startsWith("<PM>")) {
132
+ currentChapter.content.push({ type: "line_break" });
133
+ }
134
+ isPoem = /<(?:P|PO|PN|CC|CP)>/.test(tagContent);
135
+ currentVerse = {
136
+ type: "verse",
137
+ number: vNum,
138
+ content: []
139
+ };
140
+ currentChapter.content.push(currentVerse);
141
+ }
142
+ }
143
+ }
144
+ if (lastIndex < text.length) {
145
+ const content = text.substring(lastIndex);
146
+ if (currentVerse && currentChapter) {
147
+ this.parseVerseContent(
148
+ content,
149
+ currentVerse,
150
+ currentChapter,
151
+ isPoem
152
+ );
153
+ }
154
+ }
155
+ return roots;
156
+ }
157
+ getBookIdFromVerseTag(tagContent) {
158
+ const match = tagContent.match(/\{\{(\d+)::/);
159
+ if (!match) {
160
+ return null;
161
+ }
162
+ const bookNumber = parseInt(match[1], 10);
163
+ if (isNaN(bookNumber)) {
164
+ return null;
165
+ }
166
+ return bookNumberIdMap.get(bookNumber) ?? null;
167
+ }
168
+ parseVerseContent(text, verse, chapter, isPoem) {
169
+ let cleanText = text.replace(/\s+/g, " ").trim();
170
+ cleanText = cleanText.replace(/[\+\-][“‘"]/g, "");
171
+ cleanText = cleanText.replace(/\+\[/g, "[").replace(/\+\]/g, "]");
172
+ cleanText = cleanText.replace(/@\[.*?@\]/g, "");
173
+ const segmentRegex = /(<\$F.*?\$E>)|(<\$R.*?\$RE>)|(<[^>]*>)|(\{.*?\})/g;
174
+ let lastIdx = 0;
175
+ let m;
176
+ let wordsOfJesus = false;
177
+ while ((m = segmentRegex.exec(cleanText)) !== null) {
178
+ const snippet = cleanText.substring(lastIdx, m.index);
179
+ if (snippet) {
180
+ this.addText(verse, snippet, isPoem, wordsOfJesus);
181
+ }
182
+ if (m[1]) {
183
+ this.processFootnote(m[1], verse, chapter);
184
+ } else if (m[2]) {
185
+ } else if (m[3]) {
186
+ if (m[3] === "<PO>") {
187
+ verse.content.push({ lineBreak: true });
188
+ lastIdx = segmentRegex.lastIndex;
189
+ continue;
190
+ }
191
+ if (m[3] === "<RS>") {
192
+ wordsOfJesus = true;
193
+ } else if (m[3] === "</RS>") {
194
+ wordsOfJesus = false;
195
+ }
196
+ } else if (m[4]) {
197
+ const content = m[4].substring(1, m[4].length - 1);
198
+ if (content) {
199
+ let text2 = {
200
+ text: content,
201
+ italics: true
202
+ };
203
+ if (isPoem) {
204
+ text2.poem = 1;
205
+ }
206
+ if (wordsOfJesus) {
207
+ text2.wordsOfJesus = true;
208
+ }
209
+ verse.content.push(text2);
210
+ }
211
+ }
212
+ lastIdx = segmentRegex.lastIndex;
213
+ }
214
+ const remaining = cleanText.substring(lastIdx);
215
+ if (remaining) {
216
+ this.addText(verse, remaining, isPoem, wordsOfJesus);
217
+ }
218
+ }
219
+ addText(verse, text, isPoem, wordsOfJesus) {
220
+ if (!text) return;
221
+ if (isPoem || wordsOfJesus) {
222
+ const lastItem = verse.content[verse.content.length - 1];
223
+ if (lastItem && typeof lastItem !== "string" && !("noteId" in lastItem) && lastItem.poem === (isPoem ? 1 : void 0) && lastItem.wordsOfJesus === (wordsOfJesus ? true : void 0) && !lastItem.italics) {
224
+ lastItem.text += text;
225
+ } else {
226
+ const formatted = {
227
+ text
228
+ };
229
+ if (isPoem) {
230
+ formatted.poem = 1;
231
+ }
232
+ if (wordsOfJesus) {
233
+ formatted.wordsOfJesus = true;
234
+ }
235
+ verse.content.push(formatted);
236
+ }
237
+ } else {
238
+ const lastItem = verse.content[verse.content.length - 1];
239
+ if (typeof lastItem === "string") {
240
+ verse.content[verse.content.length - 1] = lastItem + text;
241
+ } else {
242
+ verse.content.push(text);
243
+ }
244
+ }
245
+ }
246
+ parseHebrewSubtitleContent(text, subtitle, chapter) {
247
+ let cleanText = text.replace(/\s+/g, " ").trim();
248
+ cleanText = cleanText.replace(/[{}]/g, "");
249
+ cleanText = cleanText.replace(/@\[.*?@\]/g, "");
250
+ const segmentRegex = /(<\$F.*?\$E>)|(<\$R.*?\$RE>)|(<[^>]+>)|(\{.*?\})/g;
251
+ let lastIdx = 0;
252
+ let m;
253
+ while ((m = segmentRegex.exec(cleanText)) !== null) {
254
+ const snippet = cleanText.substring(lastIdx, m.index);
255
+ if (snippet) {
256
+ this.addSubtitleText(subtitle, snippet);
257
+ }
258
+ if (m[1]) {
259
+ const ref = this.processFootnoteForSubtitle(m[1], chapter);
260
+ if (ref) {
261
+ subtitle.content.push(ref);
262
+ }
263
+ } else if (m[2]) {
264
+ } else if (m[3]) {
265
+ } else if (m[4]) {
266
+ const content = m[4].substring(1, m[4].length - 1);
267
+ if (content) {
268
+ this.addSubtitleText(subtitle, content);
269
+ }
270
+ }
271
+ lastIdx = segmentRegex.lastIndex;
272
+ }
273
+ const remaining = cleanText.substring(lastIdx);
274
+ if (remaining) {
275
+ this.addSubtitleText(subtitle, remaining);
276
+ }
277
+ }
278
+ addSubtitleText(subtitle, text) {
279
+ if (!text) return;
280
+ const lastItem = subtitle.content[subtitle.content.length - 1];
281
+ if (typeof lastItem === "string") {
282
+ subtitle.content[subtitle.content.length - 1] = lastItem + text;
283
+ } else {
284
+ subtitle.content.push(text);
285
+ }
286
+ }
287
+ processFootnote(block, verse, chapter) {
288
+ const text = this.extractFootnoteText(block);
289
+ if (!text) return;
290
+ const noteId = chapter.footnotes.length + 1;
291
+ const fn = {
292
+ noteId,
293
+ text,
294
+ caller: "+",
295
+ reference: {
296
+ chapter: chapter.number,
297
+ verse: verse.number
298
+ }
299
+ };
300
+ chapter.footnotes.push(fn);
301
+ verse.content.push({
302
+ noteId
303
+ });
304
+ }
305
+ processFootnoteForSubtitle(block, chapter) {
306
+ const text = this.extractFootnoteText(block);
307
+ if (!text) return null;
308
+ const noteId = chapter.footnotes.length + 1;
309
+ const fn = {
310
+ noteId,
311
+ text,
312
+ caller: "+",
313
+ reference: {
314
+ chapter: chapter.number,
315
+ verse: 0
316
+ }
317
+ };
318
+ chapter.footnotes.push(fn);
319
+ return {
320
+ noteId
321
+ };
322
+ }
323
+ extractFootnoteText(block) {
324
+ let inner = block.replace(/^<\$F/, "").replace(/\$E>$/, "");
325
+ inner = inner.replace(/<FN>.*?<\/FN>/g, "");
326
+ return inner.replace(/<[^>]+>/g, "").replace(/[\{\}]/g, "").trim();
327
+ }
328
+ }
329
+ // Annotate the CommonJS export names for ESM import in node:
330
+ 0 && (module.exports = {
331
+ LOCKMAN_PARSER_VERSION,
332
+ LockmanParser
333
+ });
334
+ //# sourceMappingURL=lockman-parser.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../parser/lockman-parser.ts"],
4
+ "sourcesContent": ["import {\r\n ParseTree,\r\n Chapter,\r\n Verse,\r\n Heading,\r\n Footnote,\r\n Text,\r\n FootnoteReference,\r\n HebrewSubtitle,\r\n} from './types.js';\r\nimport { bookOrderMap } from '../generation/book-order.js';\r\n\r\nexport const LOCKMAN_PARSER_VERSION = 3;\r\n\r\nconst bookNumberIdMap = new Map<number, string>();\r\nfor (const [id, order] of bookOrderMap) {\r\n if (!bookNumberIdMap.has(order)) {\r\n bookNumberIdMap.set(order, id);\r\n }\r\n}\r\n\r\nexport class LockmanParser {\r\n parse(text: string): ParseTree[] {\r\n const roots: ParseTree[] = [];\r\n let currentRoot: ParseTree | null = null;\r\n let currentChapter: Chapter | null = null;\r\n let currentVerse: Verse | null = null;\r\n\r\n // Splits text into tokens based on structural tags\r\n // Identify major blocks: BN, CN, SH, and Verse Starters (V, C, PM, A, PO)\r\n // Note: SH and CN content is strictly inside the tag.\r\n // Verse content follows the tag.\r\n // We use a regex that captures the tag AND its \"attributes\" like {{..}}Num<T> for verses.\r\n\r\n // Regex for structural separators\r\n // Captures:\r\n // 1. Title: <BN>...</BN>\r\n // 2. Chapter Heading: <CN>...</CN> or <SN>...</SN>\r\n // 3. Section Heading: <SH>...</SH> or <SS>...</SS>\r\n // 4. Verse Start: (<V>|<C>|<CC>|<CP>|<PM>|<A>|<PO>|<P>|<PN>){{...}}Number<T>\r\n\r\n const structureRegex =\r\n /(<BN>.*?<\\/BN>)|((?:<CN>.*?<\\/CN>)|(?:<SN>.*?<\\/SN>))|((?:<SH>.*?<\\/SH>)|(?:<SS>.*?<\\/SS>))|((?:<V>|<C>|<CC>|<CP>|<PM>|<A>|<PO>|<P>|<PN>)\\{\\{.*?\\}\\}\\d+(?:<T>|\\^)(?:\\{.*?\\})?)/g;\r\n\r\n let lastIndex = 0;\r\n let match;\r\n let isPoem = false;\r\n\r\n while ((match = structureRegex.exec(text)) !== null) {\r\n const fullMatch = match[0];\r\n const startIndex = match.index;\r\n\r\n // Content belonging to the PREVIOUS structural element\r\n if (startIndex > lastIndex) {\r\n const content = text.substring(lastIndex, startIndex);\r\n if (currentVerse && currentChapter) {\r\n this.parseVerseContent(\r\n content,\r\n currentVerse,\r\n currentChapter,\r\n isPoem\r\n );\r\n }\r\n }\r\n\r\n lastIndex = startIndex + fullMatch.length;\r\n\r\n if (match[1]) {\r\n // <BN>Title</BN>\r\n // Start of a NEW Book\r\n const title = match[1].replace(/<\\/?BN>/g, '').trim();\r\n\r\n currentRoot = {\r\n type: 'root',\r\n title: title,\r\n content: [],\r\n };\r\n roots.push(currentRoot);\r\n\r\n // Reset context for new book\r\n currentChapter = null;\r\n currentVerse = null;\r\n } else if (match[2]) {\r\n // <CN>CHAPTER 1</CN> or <SN>PSALM 1</SN>\r\n // Start new Chapter\r\n // Ensure we have a root (handle case where no <BN> provided, implicitly create one? Or just attach to last root)\r\n if (!currentRoot) {\r\n // Fallback if no <BN> was found first\r\n currentRoot = {\r\n type: 'root',\r\n content: [],\r\n };\r\n roots.push(currentRoot);\r\n }\r\n\r\n // Remove tags: <CN>, </CN>, <SN>, </SN>\r\n const inner = match[2].replace(/<\\/?(CN|SN)>/g, '').trim();\r\n const numMatch = inner.match(/\\d+/);\r\n const num = numMatch ? parseInt(numMatch[0], 10) : 0;\r\n\r\n currentChapter = {\r\n type: 'chapter',\r\n number: num,\r\n content: [],\r\n footnotes: [],\r\n };\r\n currentRoot.content.push(currentChapter);\r\n currentVerse = null;\r\n } else if (match[3]) {\r\n // <SH>Heading</SH> or <SS>Subtitle</SS>\r\n if (!currentRoot) {\r\n currentRoot = { type: 'root', content: [] };\r\n roots.push(currentRoot);\r\n }\r\n\r\n const raw = match[3];\r\n if (raw.startsWith('<SS>')) {\r\n // Hebrew subtitle in Psalms\r\n const inner = raw.replace(/<\\/?SS>/g, '').trim();\r\n const subtitle: HebrewSubtitle = {\r\n type: 'hebrew_subtitle',\r\n content: [],\r\n };\r\n\r\n if (currentChapter) {\r\n this.parseHebrewSubtitleContent(\r\n inner,\r\n subtitle,\r\n currentChapter\r\n );\r\n currentChapter.content.push(subtitle);\r\n }\r\n } else {\r\n // Section heading\r\n const inner = raw.replace(/<\\/?SH>/g, '').trim();\r\n const normalized = inner.replace(/<\\\\>|<\\/?>|[{}]/g, '');\r\n const heading: Heading = {\r\n type: 'heading',\r\n content: [normalized],\r\n };\r\n if (currentChapter) {\r\n currentChapter.content.push(heading);\r\n } else {\r\n // Start of book heading? Not typical in this structure but possible\r\n currentRoot.content.push(heading);\r\n }\r\n }\r\n } else if (match[4]) {\r\n // Verse Start: <Tag>{{Ref}}Number<T>\r\n // Extract Verse Number\r\n const tagContent = match[4];\r\n if (currentRoot && !currentRoot.id) {\r\n const bookId = this.getBookIdFromVerseTag(tagContent);\r\n if (bookId) {\r\n currentRoot.id = bookId;\r\n }\r\n }\r\n // Regex to extract digits before <T>\r\n const vNumMatch = tagContent.match(/(\\d+)(?:<T>|\\^)/);\r\n const vNum = vNumMatch ? parseInt(vNumMatch[1], 10) : 0;\r\n\r\n if (currentChapter) {\r\n // Check for Paragraph Marker\r\n if (tagContent.startsWith('<PM>')) {\r\n currentChapter.content.push({ type: 'line_break' });\r\n }\r\n\r\n // Update global isPoem flag\r\n isPoem = /<(?:P|PO|PN|CC|CP)>/.test(tagContent);\r\n\r\n currentVerse = {\r\n type: 'verse',\r\n number: vNum,\r\n content: [],\r\n };\r\n currentChapter.content.push(currentVerse);\r\n }\r\n }\r\n }\r\n\r\n // Process remaining text after the last match\r\n if (lastIndex < text.length) {\r\n const content = text.substring(lastIndex);\r\n if (currentVerse && currentChapter) {\r\n this.parseVerseContent(\r\n content,\r\n currentVerse,\r\n currentChapter,\r\n isPoem\r\n );\r\n }\r\n }\r\n\r\n return roots;\r\n }\r\n\r\n private getBookIdFromVerseTag(tagContent: string): string | null {\r\n const match = tagContent.match(/\\{\\{(\\d+)::/);\r\n if (!match) {\r\n return null;\r\n }\r\n\r\n const bookNumber = parseInt(match[1], 10);\r\n if (isNaN(bookNumber)) {\r\n return null;\r\n }\r\n\r\n return bookNumberIdMap.get(bookNumber) ?? null;\r\n }\r\n\r\n private parseVerseContent(\r\n text: string,\r\n verse: Verse,\r\n chapter: Chapter,\r\n isPoem: boolean\r\n ) {\r\n // Remove line breaks that are just formatting in the source file\r\n // But keep spaces.\r\n // The source has newlines. We should arguably treat them as spaces.\r\n let cleanText = text.replace(/\\s+/g, ' ').trim();\r\n cleanText = cleanText.replace(/[\\+\\-][\u201C\u2018\"]/g, '');\r\n cleanText = cleanText.replace(/\\+\\[/g, '[').replace(/\\+\\]/g, ']');\r\n cleanText = cleanText.replace(/@\\[.*?@\\]/g, '');\r\n\r\n // Regex to separate text from special inline blocks:\r\n // 1. Footnotes: <$F ... $E>\r\n // 2. Cross References: <$R ... $RE> (To be removed)\r\n // 3. Formatting Tags: <RA>, <N1>, etc. (To be removed?)\r\n // 4. Italics in curly braces: {text}\r\n\r\n // Note: Curly braces are nested inside footnotes sometimes, but stripped there.\r\n // At the verse level, they denote italics.\r\n\r\n const segmentRegex =\r\n /(<\\$F.*?\\$E>)|(<\\$R.*?\\$RE>)|(<[^>]*>)|(\\{.*?\\})/g;\r\n\r\n let lastIdx = 0;\r\n let m;\r\n let wordsOfJesus = false;\r\n\r\n while ((m = segmentRegex.exec(cleanText)) !== null) {\r\n const snippet = cleanText.substring(lastIdx, m.index);\r\n if (snippet) {\r\n // Add plain text\r\n this.addText(verse, snippet, isPoem, wordsOfJesus);\r\n }\r\n\r\n if (m[1]) {\r\n // Footnote <$F ... $E>\r\n this.processFootnote(m[1], verse, chapter);\r\n } else if (m[2]) {\r\n // Cross Ref -> Ignore\r\n } else if (m[3]) {\r\n if (m[3] === '<PO>') {\r\n verse.content.push({ lineBreak: true });\r\n lastIdx = segmentRegex.lastIndex;\r\n continue;\r\n }\r\n // Handle words of Jesus markers\r\n if (m[3] === '<RS>') {\r\n wordsOfJesus = true;\r\n } else if (m[3] === '</RS>') {\r\n wordsOfJesus = false;\r\n }\r\n // Other tag -> Ignore (e.g. <RA>, <N1>, <FA>)\r\n // These are often just markers or anchors.\r\n } else if (m[4]) {\r\n // Italics {text}\r\n const content = m[4].substring(1, m[4].length - 1);\r\n // We push a Text object with italics: true\r\n // Check if we need to decode inside? Usually just text.\r\n if (content) {\r\n let text: Text = {\r\n text: content,\r\n italics: true,\r\n };\r\n\r\n if (isPoem) {\r\n text.poem = 1;\r\n }\r\n\r\n if (wordsOfJesus) {\r\n text.wordsOfJesus = true;\r\n }\r\n\r\n verse.content.push(text);\r\n }\r\n }\r\n\r\n lastIdx = segmentRegex.lastIndex;\r\n }\r\n\r\n const remaining = cleanText.substring(lastIdx);\r\n if (remaining) {\r\n this.addText(verse, remaining, isPoem, wordsOfJesus);\r\n }\r\n }\r\n\r\n private addText(\r\n verse: Verse,\r\n text: string,\r\n isPoem: boolean,\r\n wordsOfJesus: boolean\r\n ) {\r\n if (!text) return;\r\n\r\n if (isPoem || wordsOfJesus) {\r\n // When poem=1 or wordsOfJesus is true, use Text objects to carry attributes.\r\n const lastItem = verse.content[verse.content.length - 1];\r\n\r\n if (\r\n lastItem &&\r\n typeof lastItem !== 'string' &&\r\n !('noteId' in lastItem) &&\r\n (lastItem as Text).poem === (isPoem ? 1 : undefined) &&\r\n (lastItem as Text).wordsOfJesus ===\r\n (wordsOfJesus ? true : undefined) &&\r\n !(lastItem as Text).italics\r\n ) {\r\n (lastItem as Text).text += text;\r\n } else {\r\n const formatted: Text = {\r\n text: text,\r\n };\r\n if (isPoem) {\r\n formatted.poem = 1;\r\n }\r\n if (wordsOfJesus) {\r\n formatted.wordsOfJesus = true;\r\n }\r\n verse.content.push(formatted);\r\n }\r\n } else {\r\n // Merge with previous string if possible\r\n const lastItem = verse.content[verse.content.length - 1];\r\n if (typeof lastItem === 'string') {\r\n verse.content[verse.content.length - 1] = lastItem + text;\r\n } else {\r\n verse.content.push(text);\r\n }\r\n }\r\n }\r\n\r\n private parseHebrewSubtitleContent(\r\n text: string,\r\n subtitle: HebrewSubtitle,\r\n chapter: Chapter\r\n ) {\r\n let cleanText = text.replace(/\\s+/g, ' ').trim();\r\n cleanText = cleanText.replace(/[{}]/g, '');\r\n cleanText = cleanText.replace(/@\\[.*?@\\]/g, '');\r\n\r\n const segmentRegex =\r\n /(<\\$F.*?\\$E>)|(<\\$R.*?\\$RE>)|(<[^>]+>)|(\\{.*?\\})/g;\r\n\r\n let lastIdx = 0;\r\n let m;\r\n\r\n while ((m = segmentRegex.exec(cleanText)) !== null) {\r\n const snippet = cleanText.substring(lastIdx, m.index);\r\n if (snippet) {\r\n this.addSubtitleText(subtitle, snippet);\r\n }\r\n\r\n if (m[1]) {\r\n const ref = this.processFootnoteForSubtitle(m[1], chapter);\r\n if (ref) {\r\n subtitle.content.push(ref);\r\n }\r\n } else if (m[2]) {\r\n // Cross Ref -> Ignore\r\n } else if (m[3]) {\r\n // Other tag -> Ignore\r\n } else if (m[4]) {\r\n const content = m[4].substring(1, m[4].length - 1);\r\n if (content) {\r\n this.addSubtitleText(subtitle, content);\r\n }\r\n }\r\n\r\n lastIdx = segmentRegex.lastIndex;\r\n }\r\n\r\n const remaining = cleanText.substring(lastIdx);\r\n if (remaining) {\r\n this.addSubtitleText(subtitle, remaining);\r\n }\r\n }\r\n\r\n private addSubtitleText(subtitle: HebrewSubtitle, text: string) {\r\n if (!text) return;\r\n\r\n const lastItem = subtitle.content[subtitle.content.length - 1];\r\n if (typeof lastItem === 'string') {\r\n subtitle.content[subtitle.content.length - 1] = lastItem + text;\r\n } else {\r\n subtitle.content.push(text);\r\n }\r\n }\r\n\r\n private processFootnote(block: string, verse: Verse, chapter: Chapter) {\r\n // block is <$F...$E>\r\n // Inner content has tags like <FN>, <FNC>, <N1>...\r\n // We want the readable text.\r\n // Remove known technical tags.\r\n\r\n const text = this.extractFootnoteText(block);\r\n\r\n if (!text) return;\r\n\r\n const noteId = chapter.footnotes.length + 1;\r\n\r\n const fn: Footnote = {\r\n noteId: noteId,\r\n text: text,\r\n caller: '+',\r\n reference: {\r\n chapter: chapter.number,\r\n verse: verse.number,\r\n },\r\n };\r\n chapter.footnotes.push(fn);\r\n\r\n verse.content.push({\r\n noteId: noteId,\r\n } as FootnoteReference);\r\n }\r\n\r\n private processFootnoteForSubtitle(\r\n block: string,\r\n chapter: Chapter\r\n ): FootnoteReference | null {\r\n const text = this.extractFootnoteText(block);\r\n\r\n if (!text) return null;\r\n\r\n const noteId = chapter.footnotes.length + 1;\r\n\r\n const fn: Footnote = {\r\n noteId: noteId,\r\n text: text,\r\n caller: '+',\r\n reference: {\r\n chapter: chapter.number,\r\n verse: 0,\r\n },\r\n };\r\n chapter.footnotes.push(fn);\r\n\r\n return {\r\n noteId: noteId,\r\n } as FootnoteReference;\r\n }\r\n\r\n private extractFootnoteText(block: string): string {\r\n // Remove outer $F...$E\r\n let inner = block.replace(/^<\\$F/, '').replace(/\\$E>$/, '');\r\n\r\n // Remove internal technical tags\r\n // Remove <FN>...</FN> completely\r\n inner = inner.replace(/<FN>.*?<\\/FN>/g, '');\r\n\r\n // Remove other tags <N1>, <FA> but keep content\r\n // Also remove italics curly braces (keep content inside)\r\n return inner\r\n .replace(/<[^>]+>/g, '')\r\n .replace(/[\\{\\}]/g, '')\r\n .trim();\r\n }\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,wBAA6B;AAEtB,MAAM,yBAAyB;AAEtC,MAAM,kBAAkB,oBAAI,IAAoB;AAChD,WAAW,CAAC,IAAI,KAAK,KAAK,gCAAc;AACpC,MAAI,CAAC,gBAAgB,IAAI,KAAK,GAAG;AAC7B,oBAAgB,IAAI,OAAO,EAAE;AAAA,EACjC;AACJ;AAEO,MAAM,cAAc;AAAA,EACvB,MAAM,MAA2B;AAC7B,UAAM,QAAqB,CAAC;AAC5B,QAAI,cAAgC;AACpC,QAAI,iBAAiC;AACrC,QAAI,eAA6B;AAejC,UAAM,iBACF;AAEJ,QAAI,YAAY;AAChB,QAAI;AACJ,QAAI,SAAS;AAEb,YAAQ,QAAQ,eAAe,KAAK,IAAI,OAAO,MAAM;AACjD,YAAM,YAAY,MAAM,CAAC;AACzB,YAAM,aAAa,MAAM;AAGzB,UAAI,aAAa,WAAW;AACxB,cAAM,UAAU,KAAK,UAAU,WAAW,UAAU;AACpD,YAAI,gBAAgB,gBAAgB;AAChC,eAAK;AAAA,YACD;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACJ;AAAA,QACJ;AAAA,MAC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jB;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,WAAW;AAAA,QACP,SAAS,QAAQ;AAAA,QACjB,OAAO,MAAM;AAAA,MACjB;AAAA,IACJ;AACA,YAAQ,UAAU,KAAK,EAAE;AAEzB,UAAM,QAAQ,KAAK;AAAA,MACf;AAAA,IACJ,CAAsB;AAAA,EAC1B;AAAA,EAEQ,2BACJ,OACA,SACwB;AACxB,UAAM,OAAO,KAAK,oBAAoB,KAAK;AAE3C,QAAI,CAAC,KAAM,QAAO;AAElB,UAAM,SAAS,QAAQ,UAAU,SAAS;AAE1C,UAAM,KAAe;AAAA,MACjB;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,WAAW;AAAA,QACP,SAAS,QAAQ;AAAA,QACjB,OAAO;AAAA,MACX;AAAA,IACJ;AACA,YAAQ,UAAU,KAAK,EAAE;AAEzB,WAAO;AAAA,MACH;AAAA,IACJ;AAAA,EACJ;AAAA,EAEQ,oBAAoB,OAAuB;AAE/C,QAAI,QAAQ,MAAM,QAAQ,SAAS,EAAE,EAAE,QAAQ,SAAS,EAAE;AAI1D,YAAQ,MAAM,QAAQ,kBAAkB,EAAE;AAI1C,WAAO,MACF,QAAQ,YAAY,EAAE,EACtB,QAAQ,WAAW,EAAE,EACrB,KAAK;AAAA,EACd;AACJ;",
6
+ "names": ["text"]
7
+ }
@@ -23,7 +23,7 @@ __export(tyndale_xml_parser_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(tyndale_xml_parser_exports);
25
25
  var import_log = require("../log.js");
26
- var import_utils = require("../utils");
26
+ var import_utils = require("../utils.js");
27
27
  var NodeType = /* @__PURE__ */ ((NodeType2) => {
28
28
  NodeType2[NodeType2["Element"] = 1] = "Element";
29
29
  NodeType2[NodeType2["Attribute"] = 2] = "Attribute";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../parser/tyndale-xml-parser.ts"],
4
- "sourcesContent": ["import { getLogger } from '../log.js';\nimport { parseVerseReference } from '../utils';\nimport {\n CommentaryBookNode,\n CommentaryChapterNode,\n CommentaryParseTree,\n CommentaryVerseNode,\n} from './types';\n\nenum NodeType {\n Element = 1,\n Attribute = 2,\n Text = 3,\n}\n\nexport class TyndaleXmlParser {\n private _domParser: DOMParser;\n\n constructor(domParser: DOMParser) {\n this._domParser = domParser;\n }\n\n parse(xml: string): CommentaryParseTree {\n const logger = getLogger();\n const parser = this._domParser;\n const doc = parser.parseFromString(xml, 'application/xml');\n const rootElement = doc.documentElement;\n\n let tree: CommentaryParseTree = {\n type: 'commentary/root',\n books: [],\n };\n\n let books: Map<string, CommentaryBookNode> = new Map();\n\n function getBook(id: string): CommentaryBookNode {\n let bookNode = books.get(id);\n\n if (!bookNode) {\n bookNode = {\n type: 'book',\n book: id,\n introduction: null,\n chapters: [],\n };\n\n books.set(id, bookNode);\n tree.books.push(bookNode);\n }\n return bookNode;\n }\n\n function getChapter(\n book: CommentaryBookNode,\n number: number\n ): CommentaryChapterNode {\n let chapterNode = book.chapters.find(\n (chapter) => chapter.number === number\n );\n\n if (!chapterNode) {\n chapterNode = {\n type: 'chapter',\n number: number,\n introduction: null,\n verses: [],\n };\n\n book.chapters.push(chapterNode);\n }\n\n return chapterNode;\n }\n\n function getVerse(\n chapter: CommentaryChapterNode,\n number: number\n ): CommentaryVerseNode {\n let verseNode = chapter.verses.find(\n (verse) => verse.number === number\n );\n\n if (!verseNode) {\n verseNode = {\n type: 'verse',\n number: number,\n content: [],\n };\n\n chapter.verses.push(verseNode);\n }\n\n return verseNode;\n }\n\n function formatContent(node: Node, trim: boolean = true): string {\n let text: string;\n if (node.nodeName === 'p') {\n text = (node.textContent || '') + '\\n';\n } else if (node.nodeName === '#text') {\n text = node.textContent || '';\n } else if (node.nodeName === 'br') {\n text = '\\n';\n } else if (node.nodeType === NodeType.Element) {\n text = '';\n for (let child of node.childNodes) {\n text += formatContent(child, false);\n }\n } else {\n text = node.textContent || '';\n }\n\n if (trim) {\n const lines = text.split('\\n');\n for (let i = 0; i < lines.length; i++) {\n // Trim extra whitespace and replace multiple spaces with a single space\n lines[i] = lines[i].replace(/\\s+/g, ' ').trim();\n }\n text = lines.join('\\n').trim();\n }\n\n return text;\n }\n\n const items = rootElement.querySelectorAll('item');\n\n for (let item of items) {\n const typename = item.getAttribute('typename');\n\n if (typename === 'StudyNote') {\n const refs = item.querySelector('refs')?.textContent;\n const body = item.querySelector('body');\n\n if (!refs || !body) {\n logger.warn(\n 'Skipping study note item without refs or body:',\n item\n );\n continue;\n }\n\n const ref = parseVerseReference(refs);\n\n if (!ref) {\n logger.warn('Failed to parse verse reference:', refs);\n continue;\n }\n\n const bookNode = getBook(ref.book);\n const chapterNode = getChapter(bookNode, ref.chapter);\n const verseNode = getVerse(chapterNode, ref.verse);\n verseNode.content.push(formatContent(body));\n } else if (typename === 'BookIntro') {\n const refs = item.querySelector('refs')?.textContent;\n const body = item.querySelector('body');\n\n if (!refs || !body) {\n logger.warn(\n 'Skipping book item without refs or body:',\n item\n );\n continue;\n }\n\n const ref = parseVerseReference(refs);\n\n if (!ref) {\n logger.warn('Failed to parse verse reference:', refs);\n continue;\n }\n\n const bookNode = getBook(ref.book);\n\n bookNode.introduction = formatContent(body);\n } else if (typename === 'BookIntroSummary') {\n const refs = item.querySelector('refs')?.textContent;\n const body = item.querySelector('body');\n\n if (!refs || !body) {\n logger.warn(\n 'Skipping book item without refs or body:',\n item\n );\n continue;\n }\n\n const ref = parseVerseReference(refs);\n\n if (!ref) {\n logger.warn('Failed to parse verse reference:', refs);\n continue;\n }\n\n const bookNode = getBook(ref.book);\n\n bookNode.introductionSummary = formatContent(body);\n } else if (typename === 'Profile') {\n const refs = item.querySelector('refs')?.textContent;\n const body = item.querySelector('body');\n const title = item.querySelector('title')?.textContent;\n const name = item.getAttribute('name');\n\n if (!refs || !body || !title || !name) {\n logger.warn(\n 'Skipping profile item without refs, body, or title:',\n item\n );\n continue;\n }\n\n const ref = parseVerseReference(refs);\n\n if (!ref) {\n logger.warn('Failed to parse verse reference:', refs);\n continue;\n }\n\n if (!tree.profiles) {\n tree.profiles = [];\n }\n\n // convert camelCase to kebab-case\n const id = toKebabCase(name);\n tree.profiles.push({\n id,\n subject: title,\n content: [formatContent(body)],\n reference: ref,\n });\n }\n }\n\n return tree;\n }\n}\n\nexport function toKebabCase(camelCase: string): string {\n return camelCase.replace(/([a-z])\\s*([A-Z])/g, '$1-$2').toLowerCase();\n}\n"],
4
+ "sourcesContent": ["import { getLogger } from '../log.js';\r\nimport { parseVerseReference } from '../utils.js';\r\nimport {\r\n CommentaryBookNode,\r\n CommentaryChapterNode,\r\n CommentaryParseTree,\r\n CommentaryVerseNode,\r\n} from './types.js';\r\n\r\nenum NodeType {\r\n Element = 1,\r\n Attribute = 2,\r\n Text = 3,\r\n}\r\n\r\nexport class TyndaleXmlParser {\r\n private _domParser: DOMParser;\r\n\r\n constructor(domParser: DOMParser) {\r\n this._domParser = domParser;\r\n }\r\n\r\n parse(xml: string): CommentaryParseTree {\r\n const logger = getLogger();\r\n const parser = this._domParser;\r\n const doc = parser.parseFromString(xml, 'application/xml');\r\n const rootElement = doc.documentElement;\r\n\r\n let tree: CommentaryParseTree = {\r\n type: 'commentary/root',\r\n books: [],\r\n };\r\n\r\n let books: Map<string, CommentaryBookNode> = new Map();\r\n\r\n function getBook(id: string): CommentaryBookNode {\r\n let bookNode = books.get(id);\r\n\r\n if (!bookNode) {\r\n bookNode = {\r\n type: 'book',\r\n book: id,\r\n introduction: null,\r\n chapters: [],\r\n };\r\n\r\n books.set(id, bookNode);\r\n tree.books.push(bookNode);\r\n }\r\n return bookNode;\r\n }\r\n\r\n function getChapter(\r\n book: CommentaryBookNode,\r\n number: number\r\n ): CommentaryChapterNode {\r\n let chapterNode = book.chapters.find(\r\n (chapter) => chapter.number === number\r\n );\r\n\r\n if (!chapterNode) {\r\n chapterNode = {\r\n type: 'chapter',\r\n number: number,\r\n introduction: null,\r\n verses: [],\r\n };\r\n\r\n book.chapters.push(chapterNode);\r\n }\r\n\r\n return chapterNode;\r\n }\r\n\r\n function getVerse(\r\n chapter: CommentaryChapterNode,\r\n number: number\r\n ): CommentaryVerseNode {\r\n let verseNode = chapter.verses.find(\r\n (verse) => verse.number === number\r\n );\r\n\r\n if (!verseNode) {\r\n verseNode = {\r\n type: 'verse',\r\n number: number,\r\n content: [],\r\n };\r\n\r\n chapter.verses.push(verseNode);\r\n }\r\n\r\n return verseNode;\r\n }\r\n\r\n function formatContent(node: Node, trim: boolean = true): string {\r\n let text: string;\r\n if (node.nodeName === 'p') {\r\n text = (node.textContent || '') + '\\n';\r\n } else if (node.nodeName === '#text') {\r\n text = node.textContent || '';\r\n } else if (node.nodeName === 'br') {\r\n text = '\\n';\r\n } else if (node.nodeType === NodeType.Element) {\r\n text = '';\r\n for (let child of node.childNodes) {\r\n text += formatContent(child, false);\r\n }\r\n } else {\r\n text = node.textContent || '';\r\n }\r\n\r\n if (trim) {\r\n const lines = text.split('\\n');\r\n for (let i = 0; i < lines.length; i++) {\r\n // Trim extra whitespace and replace multiple spaces with a single space\r\n lines[i] = lines[i].replace(/\\s+/g, ' ').trim();\r\n }\r\n text = lines.join('\\n').trim();\r\n }\r\n\r\n return text;\r\n }\r\n\r\n const items = rootElement.querySelectorAll('item');\r\n\r\n for (let item of items) {\r\n const typename = item.getAttribute('typename');\r\n\r\n if (typename === 'StudyNote') {\r\n const refs = item.querySelector('refs')?.textContent;\r\n const body = item.querySelector('body');\r\n\r\n if (!refs || !body) {\r\n logger.warn(\r\n 'Skipping study note item without refs or body:',\r\n item\r\n );\r\n continue;\r\n }\r\n\r\n const ref = parseVerseReference(refs);\r\n\r\n if (!ref) {\r\n logger.warn('Failed to parse verse reference:', refs);\r\n continue;\r\n }\r\n\r\n const bookNode = getBook(ref.book);\r\n const chapterNode = getChapter(bookNode, ref.chapter);\r\n const verseNode = getVerse(chapterNode, ref.verse);\r\n verseNode.content.push(formatContent(body));\r\n } else if (typename === 'BookIntro') {\r\n const refs = item.querySelector('refs')?.textContent;\r\n const body = item.querySelector('body');\r\n\r\n if (!refs || !body) {\r\n logger.warn(\r\n 'Skipping book item without refs or body:',\r\n item\r\n );\r\n continue;\r\n }\r\n\r\n const ref = parseVerseReference(refs);\r\n\r\n if (!ref) {\r\n logger.warn('Failed to parse verse reference:', refs);\r\n continue;\r\n }\r\n\r\n const bookNode = getBook(ref.book);\r\n\r\n bookNode.introduction = formatContent(body);\r\n } else if (typename === 'BookIntroSummary') {\r\n const refs = item.querySelector('refs')?.textContent;\r\n const body = item.querySelector('body');\r\n\r\n if (!refs || !body) {\r\n logger.warn(\r\n 'Skipping book item without refs or body:',\r\n item\r\n );\r\n continue;\r\n }\r\n\r\n const ref = parseVerseReference(refs);\r\n\r\n if (!ref) {\r\n logger.warn('Failed to parse verse reference:', refs);\r\n continue;\r\n }\r\n\r\n const bookNode = getBook(ref.book);\r\n\r\n bookNode.introductionSummary = formatContent(body);\r\n } else if (typename === 'Profile') {\r\n const refs = item.querySelector('refs')?.textContent;\r\n const body = item.querySelector('body');\r\n const title = item.querySelector('title')?.textContent;\r\n const name = item.getAttribute('name');\r\n\r\n if (!refs || !body || !title || !name) {\r\n logger.warn(\r\n 'Skipping profile item without refs, body, or title:',\r\n item\r\n );\r\n continue;\r\n }\r\n\r\n const ref = parseVerseReference(refs);\r\n\r\n if (!ref) {\r\n logger.warn('Failed to parse verse reference:', refs);\r\n continue;\r\n }\r\n\r\n if (!tree.profiles) {\r\n tree.profiles = [];\r\n }\r\n\r\n // convert camelCase to kebab-case\r\n const id = toKebabCase(name);\r\n tree.profiles.push({\r\n id,\r\n subject: title,\r\n content: [formatContent(body)],\r\n reference: ref,\r\n });\r\n }\r\n }\r\n\r\n return tree;\r\n }\r\n}\r\n\r\nexport function toKebabCase(camelCase: string): string {\r\n return camelCase.replace(/([a-z])\\s*([A-Z])/g, '$1-$2').toLowerCase();\r\n}\r\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA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AAA,YACA;AAAA,UACJ;AACA;AAAA,QACJ;AAEA,cAAM,UAAM,kCAAoB,IAAI;AAEpC,YAAI,CAAC,KAAK;AACN,iBAAO,KAAK,oCAAoC,IAAI;AACpD;AAAA,QACJ;AAEA,YAAI,CAAC,KAAK,UAAU;AAChB,eAAK,WAAW,CAAC;AAAA,QACrB;AAGA,cAAM,KAAK,YAAY,IAAI;AAC3B,aAAK,SAAS,KAAK;AAAA,UACf;AAAA,UACA,SAAS;AAAA,UACT,SAAS,CAAC,cAAc,IAAI,CAAC;AAAA,UAC7B,WAAW;AAAA,QACf,CAAC;AAAA,MACL;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;AAEO,SAAS,YAAY,WAA2B;AACnD,SAAO,UAAU,QAAQ,sBAAsB,OAAO,EAAE,YAAY;AACxE;",
6
6
  "names": ["NodeType"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../parser/types.ts"],
4
- "sourcesContent": ["import { VerseRef } from '../utils.js';\n\n/**\n * The parse tree that is gathered.\n */\nexport interface ParseTree {\n type: 'root';\n\n /**\n * The ID of the parse tree.\n */\n id?: string;\n\n /**\n * The header that was associated with the tree.\n */\n header?: string;\n\n /**\n * The major title that was associated with the tree.\n */\n title?: string;\n\n /**\n * The list of chapters for the tree.\n */\n content: (Heading | Chapter)[];\n\n /**\n * The list of messages that were generated during parsing.\n */\n parseMessages?: ParseMessage[];\n}\n\nexport interface ParseMessage {\n type: 'warning' | 'error';\n message: string;\n}\n\nexport interface Heading {\n type: 'heading';\n content: string[];\n}\n\nexport type ChapterContent = Heading | Verse | HebrewSubtitle | LineBreak;\n\nexport type VerseContent = string | FootnoteReference | Text;\n\n/**\n * Defines an interface that represents a chapter.\n */\nexport interface Chapter {\n type: 'chapter';\n number: number;\n\n /**\n * The contents of the chapter.\n */\n content: ChapterContent[];\n\n /**\n * The list of footnotes for the chapter.\n */\n footnotes: Footnote[];\n}\n\n/**\n * Defines an interface that represents a hebrew subtitle.\n */\nexport interface HebrewSubtitle {\n type: 'hebrew_subtitle';\n\n /**\n * The contents of the subtitle.\n */\n content: (string | Text | FootnoteReference)[];\n}\n\n/**\n * Defines an interface that represents a verse.\n */\nexport interface Verse {\n type: 'verse';\n\n number: number;\n\n /**\n * The contents of the verse.\n */\n content: (\n | string\n | Text\n | InlineHeading\n | InlineLineBreak\n | FootnoteReference\n )[];\n}\n\n/**\n * Defines an interface that represents text that has some markup attributes applied to it.\n */\nexport interface Text {\n /**\n * The text that is contained.\n */\n text: string;\n\n /**\n * Whether the text represents a poem.\n * The number indicates the level of indent.\n */\n poem?: number;\n\n /**\n * Whether the text contains the words of Jesus.\n */\n wordsOfJesus?: boolean;\n\n /**\n * Whether the text is descriptive.\n *\n * This is only used for \"hebrew subtitles\" that are included inside the verse markers.\n */\n descriptive?: boolean;\n}\n\n/**\n * Defines an interface that represents a heading that is embedded in a verse.\n */\nexport interface InlineHeading {\n /**\n * The text of the heading.\n */\n heading: string;\n}\n\n/**\n * Defines an interface that represents a line break that is embedded in a verse.\n */\nexport interface InlineLineBreak {\n lineBreak: true;\n}\n\nexport interface FootnoteReference {\n /**\n * The ID of the note that is referenced.\n */\n noteId: number;\n}\n\nexport interface Footnote {\n noteId: number;\n\n /**\n * The text of the footnote.\n */\n text: string;\n\n /**\n * The caller that should be used for the footnote.\n * For footnotes, a \"caller\" is the character that is used in the text to reference to footnote.\n *\n * For example, in the text:\n * Hello (a) World\n *\n * ----\n * (a) This is a footnote.\n *\n * The \"(a)\" is the caller.\n *\n * If \"+\", then the caller should be autogenerated.\n * If null, then the caller should be empty.\n * If a string, then the caller should be that string.\n */\n caller: '+' | string | null;\n\n /**\n * The verse reference for the footnote.\n */\n reference?: {\n chapter: number;\n verse: number;\n };\n}\n\nexport interface LineBreak {\n type: 'line_break';\n}\n\n/**\n * The parse tree that is gathered.\n */\nexport interface CommentaryParseTree {\n type: 'commentary/root';\n\n /**\n * The books that are contained in the commentary.\n */\n books: CommentaryBookNode[];\n\n /**\n * The profiles that are contained in the commentary.\n */\n profiles?: CommentaryProfileNode[];\n}\n\nexport interface CommentaryBookNode {\n type: 'book';\n book: string;\n introduction: string | null;\n introductionSummary?: string | null;\n chapters: CommentaryChapterNode[];\n}\n\nexport interface CommentaryProfileNode {\n /**\n * The ID of the profile.\n * Used to identify the profile within a commentary.\n */\n id: string;\n\n /**\n * The subject(s) of the profile.\n */\n subject: string;\n\n /**\n * The Bible reference that the profile is associated with.\n */\n reference: VerseRef | null;\n\n /**\n * The content of the profile.\n */\n content: string[];\n}\n\nexport interface CommentaryChapterNode {\n type: 'chapter';\n number: number;\n introduction: string | null;\n verses: CommentaryVerseNode[];\n}\n\nexport interface CommentaryVerseNode {\n type: 'verse';\n number: number;\n content: string[];\n}\n"],
4
+ "sourcesContent": ["import { VerseRef } from '../utils.js';\r\n\r\n/**\r\n * The parse tree that is gathered.\r\n */\r\nexport interface ParseTree {\r\n type: 'root';\r\n\r\n /**\r\n * The ID of the parse tree.\r\n */\r\n id?: string;\r\n\r\n /**\r\n * The header that was associated with the tree.\r\n */\r\n header?: string;\r\n\r\n /**\r\n * The major title that was associated with the tree.\r\n */\r\n title?: string;\r\n\r\n /**\r\n * The list of chapters for the tree.\r\n */\r\n content: (Heading | Chapter)[];\r\n\r\n /**\r\n * The list of messages that were generated during parsing.\r\n */\r\n parseMessages?: ParseMessage[];\r\n}\r\n\r\nexport interface ParseMessage {\r\n type: 'warning' | 'error';\r\n message: string;\r\n}\r\n\r\nexport interface Heading {\r\n type: 'heading';\r\n content: string[];\r\n}\r\n\r\nexport type ChapterContent = Heading | Verse | HebrewSubtitle | LineBreak;\r\n\r\nexport type VerseContent = string | FootnoteReference | Text;\r\n\r\n/**\r\n * Defines an interface that represents a chapter.\r\n */\r\nexport interface Chapter {\r\n type: 'chapter';\r\n number: number;\r\n\r\n /**\r\n * The contents of the chapter.\r\n */\r\n content: ChapterContent[];\r\n\r\n /**\r\n * The list of footnotes for the chapter.\r\n */\r\n footnotes: Footnote[];\r\n\r\n /**\r\n * The word-level annotations for the chapter's verses.\r\n * Undefined if the source didn't contain any word-level annotations.\r\n */\r\n words?: ChapterWords;\r\n}\r\n\r\n/**\r\n * Defines the word-level annotations for a chapter, keyed by verse number.\r\n */\r\nexport type ChapterWords = {\r\n [verseNumber: string]: ChapterWord[];\r\n};\r\n\r\n/**\r\n * Defines an interface that represents the annotations that a source associated\r\n * with a specific range of characters in a verse.\r\n *\r\n * The range is anchored to a single item of the verse's content array, so that\r\n * consumers can highlight the exact characters that an annotation applies to.\r\n */\r\nexport interface ChapterWord {\r\n /**\r\n * The index of the item in the verse's content array that the annotation applies to.\r\n */\r\n contentIndex: number;\r\n\r\n /**\r\n * The index of the first character of the annotated word in the content item's text.\r\n */\r\n start: number;\r\n\r\n /**\r\n * The index after the last character of the annotated word in the content item's text.\r\n * That is, `text.slice(start, end)` is the annotated word.\r\n */\r\n end: number;\r\n\r\n /**\r\n * The Strong's number(s) for the word.\r\n * Undefined if the source only provided other annotations for the word.\r\n */\r\n strongs?: string[];\r\n\r\n /**\r\n * The dictionary (citation) form of the word.\r\n * Taken from the `lemma` attribute.\r\n */\r\n lemma?: string;\r\n\r\n /**\r\n * The morphology parse code for the word.\r\n * Taken from the `x-morph` attribute.\r\n */\r\n morph?: string;\r\n\r\n /**\r\n * The pointer to the word in the source text, in the `<sourceName>:<location>` format.\r\n * Taken from the `srcloc` attribute.\r\n */\r\n srcloc?: string;\r\n\r\n /**\r\n * Which occurrence of the source word this word is. 1-based.\r\n * Taken from the `x-occurrence` attribute.\r\n */\r\n occurrence?: number;\r\n\r\n /**\r\n * The total number of times that the source word occurs.\r\n * Taken from the `x-occurrences` attribute.\r\n */\r\n occurrences?: number;\r\n}\r\n\r\n/**\r\n * Defines an interface that represents a hebrew subtitle.\r\n */\r\nexport interface HebrewSubtitle {\r\n type: 'hebrew_subtitle';\r\n\r\n /**\r\n * The contents of the subtitle.\r\n */\r\n content: (string | Text | FootnoteReference)[];\r\n}\r\n\r\n/**\r\n * Defines an interface that represents a verse.\r\n */\r\nexport interface Verse {\r\n type: 'verse';\r\n\r\n number: number;\r\n\r\n /**\r\n * The contents of the verse.\r\n */\r\n content: (\r\n | string\r\n | Text\r\n | InlineHeading\r\n | InlineLineBreak\r\n | FootnoteReference\r\n )[];\r\n}\r\n\r\n/**\r\n * Defines an interface that represents text that has some markup attributes applied to it.\r\n */\r\nexport interface Text {\r\n /**\r\n * The text that is contained.\r\n */\r\n text: string;\r\n\r\n /**\r\n * Whether the text represents a poem.\r\n * The number indicates the level of indent.\r\n */\r\n poem?: number;\r\n\r\n /**\r\n * Whether the text contains the words of Jesus.\r\n */\r\n wordsOfJesus?: boolean;\r\n\r\n /**\r\n * Whether the text is descriptive.\r\n *\r\n * This is only used for \"hebrew subtitles\" that are included inside the verse markers.\r\n */\r\n descriptive?: boolean;\r\n\r\n /**\r\n * Whether the text should be displayed in italics.\r\n */\r\n italics?: boolean;\r\n}\r\n\r\n/**\r\n * Defines an interface that represents a heading that is embedded in a verse.\r\n */\r\nexport interface InlineHeading {\r\n /**\r\n * The text of the heading.\r\n */\r\n heading: string;\r\n}\r\n\r\n/**\r\n * Defines an interface that represents a line break that is embedded in a verse.\r\n */\r\nexport interface InlineLineBreak {\r\n lineBreak: true;\r\n}\r\n\r\nexport interface FootnoteReference {\r\n /**\r\n * The ID of the note that is referenced.\r\n */\r\n noteId: number;\r\n}\r\n\r\nexport interface Footnote {\r\n noteId: number;\r\n\r\n /**\r\n * The text of the footnote.\r\n */\r\n text: string;\r\n\r\n /**\r\n * The caller that should be used for the footnote.\r\n * For footnotes, a \"caller\" is the character that is used in the text to reference to footnote.\r\n *\r\n * For example, in the text:\r\n * Hello (a) World\r\n *\r\n * ----\r\n * (a) This is a footnote.\r\n *\r\n * The \"(a)\" is the caller.\r\n *\r\n * If \"+\", then the caller should be autogenerated.\r\n * If null, then the caller should be empty.\r\n * If a string, then the caller should be that string.\r\n */\r\n caller: '+' | string | null;\r\n\r\n /**\r\n * The verse reference for the footnote.\r\n */\r\n reference?: {\r\n chapter: number;\r\n verse: number;\r\n };\r\n}\r\n\r\nexport interface LineBreak {\r\n type: 'line_break';\r\n}\r\n\r\n/**\r\n * The parse tree that is gathered.\r\n */\r\nexport interface CommentaryParseTree {\r\n type: 'commentary/root';\r\n\r\n /**\r\n * The books that are contained in the commentary.\r\n */\r\n books: CommentaryBookNode[];\r\n\r\n /**\r\n * The profiles that are contained in the commentary.\r\n */\r\n profiles?: CommentaryProfileNode[];\r\n}\r\n\r\nexport interface CommentaryBookNode {\r\n type: 'book';\r\n book: string;\r\n introduction: string | null;\r\n introductionSummary?: string | null;\r\n chapters: CommentaryChapterNode[];\r\n}\r\n\r\nexport interface CommentaryProfileNode {\r\n /**\r\n * The ID of the profile.\r\n * Used to identify the profile within a commentary.\r\n */\r\n id: string;\r\n\r\n /**\r\n * The subject(s) of the profile.\r\n */\r\n subject: string;\r\n\r\n /**\r\n * The Bible reference that the profile is associated with.\r\n */\r\n reference: VerseRef | null;\r\n\r\n /**\r\n * The content of the profile.\r\n */\r\n content: string[];\r\n}\r\n\r\nexport interface CommentaryChapterNode {\r\n type: 'chapter';\r\n number: number;\r\n introduction: string | null;\r\n verses: CommentaryVerseNode[];\r\n}\r\n\r\nexport interface CommentaryVerseNode {\r\n type: 'verse';\r\n number: number;\r\n content: string[];\r\n}\r\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -29,7 +29,7 @@ __export(usfm_parser_exports, {
29
29
  word: () => word
30
30
  });
31
31
  module.exports = __toCommonJS(usfm_parser_exports);
32
- var import_lodash = require("lodash");
32
+ var import_compat = require("es-toolkit/compat");
33
33
  var import_log = require("../log.js");
34
34
  class UsfmTokenizer {
35
35
  _input = "";
@@ -161,7 +161,7 @@ class UsfmParser {
161
161
  }
162
162
  if (source.length === 1) {
163
163
  if (isEnd) {
164
- const startMarker = (0, import_lodash.findLast)(
164
+ const startMarker = (0, import_compat.findLast)(
165
165
  tokens,
166
166
  (t3) => t3.kind === "marker" && t3.type === "start"
167
167
  );