codexparser 0.1.55 → 0.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # CodexParser: The Ultimate Bible Reference Parser 📖✨
2
+
3
+ Welcome to **CodexParser**, a powerful and flexible Node.js library crafted to parse, validate, and structure Bible references with ease. Whether you're extracting verses from a sermon, building a scripture app, or analyzing biblical texts, CodexParser transforms raw references like "John 3:16" or "Psalm 115:5,7,10" into rich, actionable data—complete with start and end points, SBL-style abbreviations, versification support, and validation. Dive into the Word like never before!
4
+
5
+ Built with precision and passion, CodexParser handles single verses, ranges, multi-chapter spans, and single-chapter books (looking at you, Jude!). It’s your trusty companion for navigating the sacred texts, supporting English, Septuagint (LXX), and Masoretic Text (MT) versions. Let’s unleash its power!
6
+
7
+ ---
8
+
9
+ ## Features 🌟
10
+
11
+ - **Parse Any Reference**: From "Jn 3:16" to "Psalm 115:5,7,10", it’s got you covered.
12
+ - **Structured Output**: Get book, chapter, verses, testament, start/end points, SBL abbreviations, and versification data in a clean object.
13
+ - **SBL Abbreviations**: Formatted references (e.g., "Ps. 115:5, 7, 10", "Gen. 1:1–3") with periods, en dashes for ranges, and commas with spaces for separated verses.
14
+ - **Versification Support**: Handles differences between English, LXX, and MT texts, with mappings like Psalm 115 (LXX) to Psalm 116 (MT/ENG).
15
+ - **Validation**: Checks if verses exist, with detailed error messages for invalid references.
16
+ - **Combine Passages**: Merge multiple references into a single, cohesive range.
17
+ - **Chainable API**: Fluent, intuitive method chaining for a smooth workflow.
18
+
19
+ ---
20
+
21
+ ## Installation 🚀
22
+
23
+ Grab CodexParser via npm and start parsing scripture in minutes:
24
+
25
+ ```bash
26
+ npm install codexparser
27
+ ```
28
+
29
+ Or clone it from GitHub and dive into the source:
30
+
31
+ ```bash
32
+ git clone https://github.com/jeremyam/CodexParser.git
33
+ cd CodexParser
34
+ npm install
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Quick Start ⚡
40
+
41
+ Here’s how to wield CodexParser’s might:
42
+
43
+ ```javascript
44
+ const CodexParser = require("codexparser")
45
+
46
+ const parser = new CodexParser()
47
+
48
+ // Parse comma-separated verses with LXX version
49
+ parser.bibleVersion("lxx").parse("Psalm 115:5,7,10")
50
+ console.log(parser.getPassages().first())
51
+ // Output: {
52
+ // original: "Psalm 115:5,7,10",
53
+ // book: "Psalms",
54
+ // chapter: 115,
55
+ // verses: [5, 7, 10],
56
+ // type: "comma_separated_verses",
57
+ // testament: "old",
58
+ // index: 0,
59
+ // version: { name: "Septuagint", value: "LXX", abbreviation: "lxx" },
60
+ // passages: [
61
+ // {
62
+ // book: "Psalms",
63
+ // chapter: 115,
64
+ // verse: 5,
65
+ // versification: { lxx: "115:5", mt: "116:14", eng: "116:14" }
66
+ // },
67
+ // {
68
+ // book: "Psalms",
69
+ // chapter: 115,
70
+ // verse: 7,
71
+ // versification: { lxx: "115:7", mt: "116:16", eng: "116:16" }
72
+ // },
73
+ // {
74
+ // book: "Psalms",
75
+ // chapter: 115,
76
+ // verse: 10,
77
+ // versification: { lxx: "115:10", mt: "116:19", eng: "116:19" }
78
+ // }
79
+ // ],
80
+ // scripture: {
81
+ // passage: "Psalms 115:5,7,10",
82
+ // cv: "115:5,7,10",
83
+ // hash: "psalms_115.5,7,10"
84
+ // },
85
+ // valid: true,
86
+ // start: { book: "Psalms", chapter: 115, verse: 5 },
87
+ // end: { book: "Psalms", chapter: 115, verse: 10 },
88
+ // abbr: "Ps. 115:5, 7, 10",
89
+ // reference: [Function]
90
+ // }
91
+
92
+ // Parse a verse range
93
+ console.log(parser.bibleVersion("eng").parse("Genesis 1:1-5").getPassages().first().abbr)
94
+ // Output: "Gen. 1:1–5"
95
+
96
+ // Chain it up!
97
+ console.log(parser.parse("Genesis 1:1-5, 10; 2:1-3").getPassages().combine())
98
+ // Combines into a single passage with start/end spanning the range!
99
+ ```
100
+
101
+ ---
102
+
103
+ ## API: Your Codex Arsenal 🛠️
104
+
105
+ Here’s the breakdown of CodexParser’s key methods—your tools for mastering scripture:
106
+
107
+ ### `new CodexParser()`
108
+
109
+ - **What it does**: Creates a new parser instance, ready to tackle any reference.
110
+ - **Usage**: `const parser = new CodexParser();`
111
+
112
+ ### `.scan(text)`
113
+
114
+ - **What it does**: Scans a string for Bible references, storing raw matches in `this.found`. It’s the first step in parsing—think of it as your scripture radar.
115
+ - **Args**: `text` (string) - The text to search (e.g., "Preaching from Jn 3:16 today").
116
+ - **Returns**: The parser instance for chaining.
117
+ - **Example**: `parser.scan("Jn 3:16; Gen 1:1");`
118
+
119
+ ### `.parse(reference)`
120
+
121
+ - **What it does**: Takes a reference string, scans it, and builds structured passage objects with `start`, `end`, `passages`, SBL abbreviations, versification, and validation. This is your main parsing powerhouse.
122
+ - **Args**: `reference` (string) - The Bible reference (e.g., "Psalm 115:5,7,10").
123
+ - **Returns**: The parser instance for chaining.
124
+ - **Example**: `parser.parse("Exodus 20:1-5").getPassages();`
125
+
126
+ ### `.bibleVersion(version)`
127
+
128
+ - **What it does**: Sets the Bible version (e.g., "lxx", "mt", "eng") to adjust versification. Great for Old Testament nerds!
129
+ - **Args**: `version` (string) - Version code ("lxx", "mt", "eng", etc.).
130
+ - **Returns**: The parser instance for chaining.
131
+ - **Example**: `parser.bibleVersion("lxx").parse("Psalm 115:5,7,10");`
132
+
133
+ ### `.getPassages()`
134
+
135
+ - **What it does**: Returns an array of parsed passage objects with handy methods like `.first()`, `.oldTestament()`, `.newTestament()`, and `.combine()`.
136
+ - **Returns**: Array of passage objects with extra methods.
137
+ - **Example**: `parser.parse("Matt 5:3-5").getPassages();`
138
+
139
+ ### `.first()`
140
+
141
+ - **What it does**: Grabs the first parsed passage—perfect for single-reference parsing.
142
+ - **Returns**: The first passage object or `null` if none exist.
143
+ - **Example**: `parser.parse("Luke 2:1").first();`
144
+
145
+ ### `.combine(passages)`
146
+
147
+ - **What it does**: Merges multiple passages from the same book into a single passage, calculating a unified range with `start` and `end`. Ideal for consolidating overlapping references.
148
+ - **Args**: `passages` (array) - Array of passage objects to combine.
149
+ - **Returns**: A combined passage object.
150
+ - **Example**:
151
+ ```javascript
152
+ const passages = parser.parse("John 3:16, 3:17-18").getPassages()
153
+ const combined = parser.combine(passages)
154
+ // Result: A single "John 3:16-18" passage
155
+ ```
156
+
157
+ ### `.getToc(version)`
158
+
159
+ - **What it does**: Generates a table of contents with books and their chapter/verse counts. Useful for reference or validation.
160
+ - **Args**: `version` (string, optional) - Bible version (defaults to "ESV").
161
+ - **Returns**: Object mapping books to chapter/verse data.
162
+ - **Example**: `console.log(parser.getToc());`
163
+
164
+ ### Passage Object Structure
165
+
166
+ Each parsed passage looks like this:
167
+
168
+ ```javascript
169
+ {
170
+ original: "Psalm 115:5,7,10", // Original input
171
+ book: "Psalms", // Full book name
172
+ chapter: 115, // Starting chapter
173
+ verses: [5, 7, 10], // Verse list
174
+ type: "comma_separated_verses", // Reference type
175
+ testament: "old", // Old or New Testament
176
+ index: 0, // Position in text
177
+ version: { name: "Septuagint", value: "LXX", abbreviation: "lxx" }, // Version info
178
+ passages: [ // Expanded verses
179
+ {
180
+ book: "Psalms",
181
+ chapter: 115,
182
+ verse: 5,
183
+ versification: { lxx: "115:5", mt: "116:14", eng: "116:14" }
184
+ },
185
+ {
186
+ book: "Psalms",
187
+ chapter: 115,
188
+ verse: 7,
189
+ versification: { lxx: "115:7", mt: "116:16", eng: "116:16" }
190
+ },
191
+ {
192
+ book: "Psalms",
193
+ chapter: 115,
194
+ verse: 10,
195
+ versification: { lxx: "115:10", mt: "116:19", eng: "116:19" }
196
+ }
197
+ ],
198
+ scripture: { // Formatted output
199
+ passage: "Psalms 115:5,7,10",
200
+ cv: "115:5,7,10",
201
+ hash: "psalms_115.5,7,10"
202
+ },
203
+ valid: true, // Validation status
204
+ start: { book: "Psalms", chapter: 115, verse: 5 }, // First verse
205
+ end: { book: "Psalms", chapter: 115, verse: 10 }, // Last verse
206
+ abbr: "Ps. 115:5, 7, 10", // SBL-style abbreviation with period, comma spaces
207
+ reference: [Function] // Method to get scripture.passage
208
+ }
209
+ ```
210
+
211
+ ---
212
+
213
+ ## Supported Reference Types 📜
214
+
215
+ - **Single Chapter**: `Jude 1` (whole chapter of a single-chapter book).
216
+ - **Chapter Verse**: `John 3:16` (one verse).
217
+ - **Chapter Verse Range**: `Genesis 1:1-5` (verse range in one chapter).
218
+ - **Comma Separated Verses**: `Psalm 115:5,7,10` (multiple verses in one chapter).
219
+ - **Chapter Range**: `Exodus 20-22` (full chapters).
220
+ - **Multi-Chapter Verse Range**: `Psalm 119:1-120:5` (spans chapters).
221
+
222
+ ---
223
+
224
+ ## Contributing 🙌
225
+
226
+ Want to enhance CodexParser? Fork it, tweak it, and send a pull request! Issues and ideas are welcome on the [GitHub Issues page](https://github.com/jeremyam/CodexParser/issues).
227
+
228
+ ---
229
+
230
+ ## License ⚖️
231
+
232
+ [MIT License](LICENSE) - Free to use, modify, and share. Spread the Word!
233
+
234
+ ---
235
+
236
+ ## Acknowledgements 🌍
237
+
238
+ Built with love by [jeremyam], powered by coffee and scripture.
239
+
240
+ ---
241
+
242
+ Let’s parse the scriptures together—happy coding! ✝️📚
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
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": {