codexparser 0.1.84 → 0.1.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.trunk/trunk.yaml CHANGED
@@ -17,7 +17,7 @@ runtimes:
17
17
  # This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
18
18
  lint:
19
19
  enabled:
20
- - checkov@3.2.446
20
+ - checkov@3.2.447
21
21
  - git-diff-check
22
22
  - markdownlint@0.45.0
23
23
  - osv-scanner@2.0.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.1.84",
3
+ "version": "0.1.86",
4
4
  "description": "This is a Javascript Bible parser and text scanner. It will search through texts and collate all scripture references into an array and parse them into objects, and it will parse passages into objects by book, chapter, verse, and testament. ",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,28 +24,26 @@ class CodexParser {
24
24
  * Initializes the parser with default properties and data.
25
25
  */
26
26
  constructor(config = {}) {
27
- this.found = [] // Array to store detected references
28
- this.passages = [] // Array to store parsed passages
29
- this.bible = bible // Bible data (Old/New Testament books)
30
- this.bookRegex = bookRegex // Regex for book names
31
- this.chapterRegex = chapterRegex // Regex for chapters
32
- this.verseRegex = verseRegex // Regex for verses
33
- this.scripturesRegex = scripturesRegex // Regex for full references
34
- this.abbreviations = abbreviations // Book abbreviation mappings
35
- this.sblAbbreviations = sblAbbreviations // SBL-style abbreviation mappings
36
- this.versificationDifferences = versified // Version-specific verse differences
27
+ this.found = []
28
+ this.passages = []
29
+ this.bible = bible
30
+ this.bookRegex = bookRegex
31
+ this.chapterRegex = chapterRegex
32
+ this.verseRegex = verseRegex
33
+ this.scripturesRegex = scripturesRegex
34
+ this.abbreviations = abbreviations
35
+ this.sblAbbreviations = sblAbbreviations
36
+ this.versificationDifferences = versified
37
37
  this.singleChapterBook = [
38
- // Books with a single chapter and their verse counts
39
38
  sch("Jude", 25),
40
39
  sch("2 John", 13),
41
40
  sch("3 John", 15),
42
41
  sch("Obadiah", 21),
43
42
  sch("Philemon", 25),
44
43
  ]
45
- this.chapterVerses = chapter_verses // Chapter-verse mappings
46
- this.error = false // Error flag
47
- this.version = null // Bible version (e.g., lxx, mt, eng)
48
- // Reference type constants
44
+ this.chapterVerses = chapter_verses
45
+ this.error = false
46
+ this.version = null
49
47
  this.SINGLE_CHAPTER = "single_chapter"
50
48
  this.CHAPTER_VERSE = "chapter_verse"
51
49
  this.CHAPTER_VERSE_RANGE = "chapter_verse_range"
@@ -96,8 +94,6 @@ class CodexParser {
96
94
  this.found = []
97
95
  // Minimal normalization: fix periods before numbers, remove trailing periods
98
96
  let normalizedText = text.replace(/\.(?=\d)/g, ":").replace(/(\b[A-Za-z]+)\.(?=\s|$)/g, "$1")
99
- console.log(`Input text: ${text}`)
100
- console.log(`Normalized text: ${normalizedText}`)
101
97
  const lowercaseBibleFullNames = fullNames.map((book) => book.toLowerCase())
102
98
  const lowercaseBibleAbbreviations = abbreviations.map((abbr) => abbr.toLowerCase())
103
99
  const lowerCaseText = normalizedText.toLowerCase()
@@ -127,8 +123,6 @@ class CodexParser {
127
123
  }
128
124
  if (i >= lowerCaseText.length) break
129
125
 
130
- console.log(`Scanning at index ${i}: ${lowerCaseText.slice(i, i + 10)}...`)
131
-
132
126
  for (let j = 0; j < lowercaseBibleFullNames.length; j++) {
133
127
  const book = lowercaseBibleFullNames[j]
134
128
  if (lowerCaseText.startsWith(book, i) && book.length > matchedLength) {
@@ -150,16 +144,14 @@ class CodexParser {
150
144
  }
151
145
 
152
146
  if (foundBook) {
153
- console.log(`Found book: ${foundBook} at index ${bookStartIndex}, length ${matchedLength}`)
154
147
  i += matchedLength
155
148
  let chapterVerse = ""
156
149
  const references = []
157
- let refStartIndex = bookStartIndex // Start of reference (including book) in normalizedText
158
- let originalRefStartIndex = bookStartIndex // Start in original text
150
+ let refStartIndex = bookStartIndex
151
+ let originalRefStartIndex = bookStartIndex
159
152
 
160
153
  while (i < normalizedText.length && isValidChapterVerseChar(normalizedText[i])) {
161
154
  if (isNextBibleBook(i)) {
162
- console.log(`Next book detected at index ${i}, stopping reference parsing`)
163
155
  break
164
156
  }
165
157
  if (normalizedText[i] === ";") {
@@ -171,9 +163,6 @@ class CodexParser {
171
163
  start: refStartIndex,
172
164
  end: refEndIndex,
173
165
  })
174
- console.log(
175
- `Reference found: ${formattedReference}, normalized indices ${refStartIndex}-${refEndIndex}`
176
- )
177
166
  }
178
167
  chapterVerse = ""
179
168
  refStartIndex = i + 1
@@ -195,9 +184,6 @@ class CodexParser {
195
184
  start: refStartIndex,
196
185
  end: refEndIndex,
197
186
  })
198
- console.log(
199
- `Final reference found: ${formattedReference}, normalized indices ${refStartIndex}-${refEndIndex}`
200
- )
201
187
  }
202
188
  }
203
189
 
@@ -207,9 +193,8 @@ class CodexParser {
207
193
  text.indexOf(originalBookText, bookStartIndex) !== -1
208
194
  ? text.indexOf(originalBookText, bookStartIndex)
209
195
  : bookStartIndex
210
- console.log(`Original book text: ${originalBookText}, original start index: ${originalBookStartIndex}`)
211
196
 
212
- references.forEach(({ ref, start, end }, refIndex) => {
197
+ references.forEach(({ ref, start, end }) => {
213
198
  let type
214
199
  if (ref.includes(":")) {
215
200
  if (ref.includes("-")) {
@@ -248,9 +233,6 @@ class CodexParser {
248
233
  text.indexOf(fullRefText, originalRefStartIndex) !== -1
249
234
  ? text.indexOf(fullRefText, originalRefStartIndex)
250
235
  : originalBookStartIndex
251
- console.log(
252
- `Searching for fullRefText: ${fullRefText} at index ${originalRefStartIndex}, found at ${originalStartIndex}`
253
- )
254
236
 
255
237
  let originalEndIndex = originalStartIndex + fullRefText.length
256
238
  let originalText = text.slice(originalStartIndex, originalEndIndex)
@@ -267,14 +249,6 @@ class CodexParser {
267
249
  originalText = text.slice(originalStartIndex, originalEndIndex)
268
250
  }
269
251
 
270
- console.log(
271
- `Reference ${
272
- refIndex + 1
273
- }: ${originalText}, original indices ${originalStartIndex}-${originalEndIndex}, type: ${type}, suffix: ${
274
- suffix || "none"
275
- }, search text: ${fullRefText}`
276
- )
277
-
278
252
  this.found.push({
279
253
  book: foundBook,
280
254
  reference: ref,
@@ -290,7 +264,6 @@ class CodexParser {
290
264
  }
291
265
  }
292
266
 
293
- console.log(`Found references: ${JSON.stringify(this.found, null, 2)}`)
294
267
  return this
295
268
  }
296
269
 
@@ -340,7 +313,6 @@ class CodexParser {
340
313
 
341
314
  // Clean reference for parsing
342
315
  let cleanReference = passage.reference.replace(/\s*(LXX|MT)$/i, "").trim()
343
- console.log(`Parsing reference: ${cleanReference}, type: ${passage.type}`)
344
316
  if (cleanReference.endsWith(",")) {
345
317
  cleanReference = cleanReference.slice(0, -1).trim()
346
318
  }
@@ -348,7 +320,6 @@ class CodexParser {
348
320
  // Handle book-only or empty references
349
321
  if (!cleanReference && this.config.booksOnly) {
350
322
  parsedPassage.type = "book_only"
351
- console.log(`Book-only reference: ${book}`)
352
323
  } else if (!cleanReference || cleanReference.match(/^\d+\s*[:;]?\s*$/)) {
353
324
  const chapterMatch = cleanReference.match(/\d+/) || ["1"]
354
325
  const chapter = Number(chapterMatch[0])
@@ -360,18 +331,13 @@ class CodexParser {
360
331
  const endVerse = chapterVerses[chapterVerses.length - 1]
361
332
  parsedPassage.verses = [`${startVerse}-${endVerse}`]
362
333
  }
363
- console.log(`Single chapter: ${chapter}, verses: ${parsedPassage.verses}`)
364
334
  } else if (passage.type === "comma_separated_verses") {
365
335
  // Handle comma-separated verses (e.g., "1:7,18")
366
336
  const [chapter, verses] = cleanReference.split(":")
367
337
  parsedPassage.chapter = Number(chapter)
368
338
  parsedPassage.verses = verses.split(",").map((v) => v.trim())
369
- console.log(`Comma-separated verses: chapter ${chapter}, verses ${parsedPassage.verses}`)
370
339
  } else {
371
340
  this.parseReferenceParts(parsedPassage, cleanReference)
372
- console.log(
373
- `Parsed with parseReferenceParts: chapter ${parsedPassage.chapter}, verses ${parsedPassage.verses}`
374
- )
375
341
  }
376
342
 
377
343
  parsedPassage.passages = this.populate(parsedPassage)
@@ -391,7 +357,6 @@ class CodexParser {
391
357
  } else {
392
358
  parsedPassage.abbr = parsedPassage.original
393
359
  }
394
- console.log(`Abbreviation set: ${parsedPassage.abbr}`)
395
360
 
396
361
  if (parsedPassage.type === this.MULTI_CHAPTER_RANGE) {
397
362
  this.handleMultiChapterRange(parsedPassage, cleanReference)
@@ -417,7 +382,6 @@ class CodexParser {
417
382
  chapter: lastPassage.chapter,
418
383
  verse: lastPassage.verse,
419
384
  }
420
- console.log(`Start: ${JSON.stringify(parsedPassage.start)}, End: ${JSON.stringify(parsedPassage.end)}`)
421
385
  }
422
386
 
423
387
  if (!parsedPassage.version) {
@@ -432,7 +396,6 @@ class CodexParser {
432
396
  })
433
397
 
434
398
  this.versification()
435
- console.log(`Final passages: ${JSON.stringify(this.passages, null, 2)}`)
436
399
  return this
437
400
  }
438
401
  /**
@@ -1,3 +1,7 @@
1
+ // Versification mappings for Malachi, aligning ESV (English), BHS (Masoretic Text), and Göttingen LXX (Septuagint).
2
+ // ESV uses 4 chapters, with 4:1–6 corresponding to BHS 3:19–24 and LXX 3:19–24.
3
+ // Note: LXX reorders verses 4–6: ESV 4:4 = LXX 3:24, ESV 4:5 = LXX 3:22, ESV 4:6 = LXX 3:23.
4
+ // Chapters 1–3 have identical versification across all three (e.g., 1:1 = 1:1).
1
5
  module.exports = {
2
6
  "4:1": {
3
7
  lxx: "3:19",
@@ -15,17 +19,17 @@ module.exports = {
15
19
  eng: "4:3",
16
20
  },
17
21
  "4:4": {
18
- lxx: "3:22",
22
+ lxx: "3:24", // Law of Moses (matches BHS 3:22 content)
19
23
  mt: "3:22",
20
24
  eng: "4:4",
21
25
  },
22
26
  "4:5": {
23
- lxx: "3:23",
27
+ lxx: "3:22", // Elijah’s coming (matches BHS 3:23 content)
24
28
  mt: "3:23",
25
29
  eng: "4:5",
26
30
  },
27
31
  "4:6": {
28
- lxx: "3:24",
32
+ lxx: "3:23", // Hearts restored (matches BHS 3:24 content)
29
33
  mt: "3:24",
30
34
  eng: "4:6",
31
35
  },