codexparser 0.0.59 → 0.0.61
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/bcv-single-test.js +6 -3
- package/jstester.js +320 -0
- package/package.json +1 -1
- package/regex-tester.js +27 -0
- package/scan-test.js +15 -3
- package/src/CodexParser.js +128 -304
- package/src/abbr.js +37 -26
- package/src/regex.js +8 -6
- package/sub-verse-scripture-test.js +3 -2
package/bcv-single-test.js
CHANGED
|
@@ -4,11 +4,14 @@ const util = require("util")
|
|
|
4
4
|
const dump = (item) => {
|
|
5
5
|
console.log(util.inspect(item, { depth: null, colors: true }))
|
|
6
6
|
}
|
|
7
|
-
const text = "
|
|
7
|
+
const text = "Malachi 3:23"
|
|
8
8
|
|
|
9
|
-
const parser = new bcv_parser(
|
|
9
|
+
const parser = new bcv_parser({
|
|
10
|
+
invalid_sequence_strategy: "include",
|
|
11
|
+
invalid_passage_strategy: "include",
|
|
12
|
+
})
|
|
10
13
|
const textParser = parser.parse(text)
|
|
11
14
|
const passages = textParser.parsed_entities()
|
|
12
15
|
passages.forEach((passage) => {
|
|
13
16
|
dump(passage)
|
|
14
|
-
})
|
|
17
|
+
})
|
package/jstester.js
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
const books = [
|
|
2
|
+
"Gen",
|
|
3
|
+
"Ge",
|
|
4
|
+
"Gn",
|
|
5
|
+
"Exo",
|
|
6
|
+
"Ex",
|
|
7
|
+
"Exod",
|
|
8
|
+
"Lev",
|
|
9
|
+
"Le",
|
|
10
|
+
"Lv",
|
|
11
|
+
"Num",
|
|
12
|
+
"Nu",
|
|
13
|
+
"Nm",
|
|
14
|
+
"Nb",
|
|
15
|
+
"Deut",
|
|
16
|
+
"Dt",
|
|
17
|
+
"Josh",
|
|
18
|
+
"Jos",
|
|
19
|
+
"Jsh",
|
|
20
|
+
"Judg",
|
|
21
|
+
"Jdg",
|
|
22
|
+
"Jg",
|
|
23
|
+
"Jdgs",
|
|
24
|
+
"Rth",
|
|
25
|
+
"Ru",
|
|
26
|
+
"Sam",
|
|
27
|
+
"Samuel",
|
|
28
|
+
"Kings",
|
|
29
|
+
"Kgs",
|
|
30
|
+
"Kin",
|
|
31
|
+
"Chron",
|
|
32
|
+
"Chronicles",
|
|
33
|
+
"Ezra",
|
|
34
|
+
"Ezr",
|
|
35
|
+
"Ez",
|
|
36
|
+
"Neh",
|
|
37
|
+
"Ne",
|
|
38
|
+
"Esth",
|
|
39
|
+
"Es",
|
|
40
|
+
"Job",
|
|
41
|
+
"Job",
|
|
42
|
+
"Jb",
|
|
43
|
+
"Pslm",
|
|
44
|
+
"Ps",
|
|
45
|
+
"Psalms",
|
|
46
|
+
"Psa",
|
|
47
|
+
"Psm",
|
|
48
|
+
"Pss",
|
|
49
|
+
"Prov",
|
|
50
|
+
"Pr",
|
|
51
|
+
"Prv",
|
|
52
|
+
"Eccles",
|
|
53
|
+
"Ec",
|
|
54
|
+
"Song",
|
|
55
|
+
"So",
|
|
56
|
+
"Canticles",
|
|
57
|
+
"Song of Songs",
|
|
58
|
+
"SOS",
|
|
59
|
+
"Isa",
|
|
60
|
+
"Is",
|
|
61
|
+
"Jer",
|
|
62
|
+
"Je",
|
|
63
|
+
"Jr",
|
|
64
|
+
"Lam",
|
|
65
|
+
"La",
|
|
66
|
+
"Ezek",
|
|
67
|
+
"Eze",
|
|
68
|
+
"Ezk",
|
|
69
|
+
"Dan",
|
|
70
|
+
"Da",
|
|
71
|
+
"Dn",
|
|
72
|
+
"Hos",
|
|
73
|
+
"Ho",
|
|
74
|
+
"Joel",
|
|
75
|
+
"Joe",
|
|
76
|
+
"Jl",
|
|
77
|
+
"Amos",
|
|
78
|
+
"Am",
|
|
79
|
+
"Obad",
|
|
80
|
+
"Ob",
|
|
81
|
+
"Jnh",
|
|
82
|
+
"Jon",
|
|
83
|
+
"Micah",
|
|
84
|
+
"Mic",
|
|
85
|
+
"Nah",
|
|
86
|
+
"Na",
|
|
87
|
+
"Hab",
|
|
88
|
+
"Zeph",
|
|
89
|
+
"Zep",
|
|
90
|
+
"Zp",
|
|
91
|
+
"Haggai",
|
|
92
|
+
"Hag",
|
|
93
|
+
"Hg",
|
|
94
|
+
"Zech",
|
|
95
|
+
"Zec",
|
|
96
|
+
"Zc",
|
|
97
|
+
"Mal",
|
|
98
|
+
"Mal",
|
|
99
|
+
"Ml",
|
|
100
|
+
"Matt",
|
|
101
|
+
"Mt",
|
|
102
|
+
"Mrk",
|
|
103
|
+
"Mk",
|
|
104
|
+
"Mr",
|
|
105
|
+
"Luk",
|
|
106
|
+
"Lk",
|
|
107
|
+
"John",
|
|
108
|
+
"Jn",
|
|
109
|
+
"Jhn",
|
|
110
|
+
"Acts",
|
|
111
|
+
"Ac",
|
|
112
|
+
"Rom",
|
|
113
|
+
"Ro",
|
|
114
|
+
"Rm",
|
|
115
|
+
"Co",
|
|
116
|
+
"Cor",
|
|
117
|
+
"Corinthians",
|
|
118
|
+
"Gal",
|
|
119
|
+
"Ga",
|
|
120
|
+
"Ephes",
|
|
121
|
+
"Eph",
|
|
122
|
+
"Phil",
|
|
123
|
+
"Php",
|
|
124
|
+
"Col",
|
|
125
|
+
"Col",
|
|
126
|
+
"Th",
|
|
127
|
+
"Thes",
|
|
128
|
+
"Thess",
|
|
129
|
+
"Thessalonians",
|
|
130
|
+
"Ti",
|
|
131
|
+
"Tim",
|
|
132
|
+
"Timothy",
|
|
133
|
+
"Titus",
|
|
134
|
+
"Tit",
|
|
135
|
+
"Philem",
|
|
136
|
+
"Phm",
|
|
137
|
+
"Hebrews",
|
|
138
|
+
"Heb",
|
|
139
|
+
"He",
|
|
140
|
+
"James",
|
|
141
|
+
"Jas",
|
|
142
|
+
"Jm",
|
|
143
|
+
"Pe",
|
|
144
|
+
"Pet",
|
|
145
|
+
"Pt",
|
|
146
|
+
"Peter",
|
|
147
|
+
"Jn",
|
|
148
|
+
"Jo",
|
|
149
|
+
"Joh",
|
|
150
|
+
"Jhn",
|
|
151
|
+
"John",
|
|
152
|
+
"Jude",
|
|
153
|
+
"Jd",
|
|
154
|
+
"Jud",
|
|
155
|
+
"Jud",
|
|
156
|
+
"Rev",
|
|
157
|
+
"The Revelation",
|
|
158
|
+
"Genesis",
|
|
159
|
+
"Exodus",
|
|
160
|
+
"Leviticus",
|
|
161
|
+
"Numbers",
|
|
162
|
+
"Deuteronomy",
|
|
163
|
+
"Joshua",
|
|
164
|
+
"Judges",
|
|
165
|
+
"Ruth",
|
|
166
|
+
"Samuel",
|
|
167
|
+
"Kings",
|
|
168
|
+
"Chronicles",
|
|
169
|
+
"Ezra",
|
|
170
|
+
"Nehemiah",
|
|
171
|
+
"Esther",
|
|
172
|
+
"Job",
|
|
173
|
+
"Psalms",
|
|
174
|
+
"Psalm",
|
|
175
|
+
"Proverbs",
|
|
176
|
+
"Ecclesiastes",
|
|
177
|
+
"Song of Solomon",
|
|
178
|
+
"Isaiah",
|
|
179
|
+
"Jeremiah",
|
|
180
|
+
"Lamentations",
|
|
181
|
+
"Ezekiel",
|
|
182
|
+
"Daniel",
|
|
183
|
+
"Hosea",
|
|
184
|
+
"Joel",
|
|
185
|
+
"Amos",
|
|
186
|
+
"Obadiah",
|
|
187
|
+
"Jonah",
|
|
188
|
+
"Micah",
|
|
189
|
+
"Nahum",
|
|
190
|
+
"Habakkuk",
|
|
191
|
+
"Zephaniah",
|
|
192
|
+
"Haggai",
|
|
193
|
+
"Zechariah",
|
|
194
|
+
"Malachi",
|
|
195
|
+
"Matthew",
|
|
196
|
+
"Mark",
|
|
197
|
+
"Luke",
|
|
198
|
+
"John",
|
|
199
|
+
"Acts",
|
|
200
|
+
"Romans",
|
|
201
|
+
"Corinthians",
|
|
202
|
+
"Galatians",
|
|
203
|
+
"Ephesians",
|
|
204
|
+
"Philippians",
|
|
205
|
+
"Colossians",
|
|
206
|
+
"Thessalonians",
|
|
207
|
+
"Timothy",
|
|
208
|
+
"Titus",
|
|
209
|
+
"Philemon",
|
|
210
|
+
"Hebrews",
|
|
211
|
+
"James",
|
|
212
|
+
"Peter",
|
|
213
|
+
"John",
|
|
214
|
+
"Revelation",
|
|
215
|
+
"Re",
|
|
216
|
+
"Ap",
|
|
217
|
+
"Jd.",
|
|
218
|
+
"Heb.",
|
|
219
|
+
]
|
|
220
|
+
|
|
221
|
+
const preStrings = ["III", "II", "I", "1st", "2nd", "3rd", "First", "Second", "Third", "1", "2", "3"]
|
|
222
|
+
const preStringed = [
|
|
223
|
+
"Sam",
|
|
224
|
+
"Samuel",
|
|
225
|
+
"Kings",
|
|
226
|
+
"Kgs",
|
|
227
|
+
"Kin",
|
|
228
|
+
"Chron",
|
|
229
|
+
"Chronicles",
|
|
230
|
+
"Corinthians",
|
|
231
|
+
"Co",
|
|
232
|
+
"Cor",
|
|
233
|
+
"Thessalonians",
|
|
234
|
+
"Th",
|
|
235
|
+
"Thes",
|
|
236
|
+
"Thess",
|
|
237
|
+
"Timothy",
|
|
238
|
+
"Ti",
|
|
239
|
+
"Tim",
|
|
240
|
+
"Peter",
|
|
241
|
+
"Pe",
|
|
242
|
+
"Pet",
|
|
243
|
+
"Pt",
|
|
244
|
+
"John",
|
|
245
|
+
"Jn",
|
|
246
|
+
"Jhn",
|
|
247
|
+
]
|
|
248
|
+
let text = `Joel 10:13 The passages Luke 2:32 and Lk 1:23 that we are looking at tonight 1 Cor 12:34 2 Cor 3:4 are found Jude 6, in Jude 5, Genesis 2:1 - 3:19, 1 John 3:16-17, 1 Peter 1:1, and Romans 10:13, 15, 17. Please turn in your Bibles. Ps 109:4,5,6,8. Isaiah 61.2-3 Mt 5.4
|
|
249
|
+
|
|
250
|
+
Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3
|
|
251
|
+
|
|
252
|
+
Jd. 5
|
|
253
|
+
Jd 6
|
|
254
|
+
|
|
255
|
+
1 Cor 12:34 2 Cor 3:4. He 4.12 Re 1.16
|
|
256
|
+
|
|
257
|
+
Leviticus 16:6 He 5.3 He 7.27
|
|
258
|
+
|
|
259
|
+
Hos 10:1-3, 8 and 1 John 2:23
|
|
260
|
+
|
|
261
|
+
exod15.18. 2 Cor 12:23 Malachi 3:32`
|
|
262
|
+
//add the prestringed versions e.g. 1 Peter
|
|
263
|
+
for (let b = 0; b < preStringed.length; b++) {
|
|
264
|
+
for (let pre = 0; pre < preStrings.length; pre++) {
|
|
265
|
+
books.push(preStrings[pre] + " " + preStringed[b])
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// add the book name with . at the end as this seems to be added sometimes, at least to the shortened forms
|
|
269
|
+
const length = books.length
|
|
270
|
+
for (let b = 0; b < length; b++) {
|
|
271
|
+
books.push(books[b] + ".")
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// sort descending - longer items first
|
|
275
|
+
books.sort((a, b) => b.length - a.length)
|
|
276
|
+
let booksAt = []
|
|
277
|
+
// go thro' each book finding where it matches in text
|
|
278
|
+
for (let b = 0; b < books.length; b++) {
|
|
279
|
+
const book = books[b]
|
|
280
|
+
let chNoInText = 0
|
|
281
|
+
while (chNoInText < text.length) {
|
|
282
|
+
let j = text.indexOf(book, chNoInText)
|
|
283
|
+
if (j < 0) break
|
|
284
|
+
if (j + book.length < text.length && !text.charAt(j + book.length).match(/^[a-z]+$/)) {
|
|
285
|
+
booksAt.push([book, j])
|
|
286
|
+
let replacement = book
|
|
287
|
+
for (let k = 0; k < book.length; k++) {
|
|
288
|
+
replacement = replacement.replace(book.charAt(k), "X")
|
|
289
|
+
}
|
|
290
|
+
text = text.replace(book, replacement) // to prevent a shorter version matching
|
|
291
|
+
}
|
|
292
|
+
chNoInText = j + book.length + 1
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// into ascending order of start position
|
|
296
|
+
booksAt.sort(function (a, b) {
|
|
297
|
+
return a[1] - b[1]
|
|
298
|
+
})
|
|
299
|
+
newText = ""
|
|
300
|
+
let chNoInText = 0
|
|
301
|
+
for (let b = 0; b < booksAt.length; b++) {
|
|
302
|
+
while (chNoInText < booksAt[b][1]) {
|
|
303
|
+
//copy across characters to start of book
|
|
304
|
+
newText += text.charAt(chNoInText)
|
|
305
|
+
chNoInText++
|
|
306
|
+
}
|
|
307
|
+
newText += booksAt[b][0]
|
|
308
|
+
chNoInText += booksAt[b][0].length //skip the 'fill-in characters
|
|
309
|
+
for (let i = 0; i < 100; i++) {
|
|
310
|
+
chNoInText++
|
|
311
|
+
const nextCh = text.charAt(chNoInText)
|
|
312
|
+
//test whether are at the end of the chapter(s) and verse(s)
|
|
313
|
+
if (nextCh.match(/^[a-z]+$/)) break
|
|
314
|
+
if (nextCh.match(/^[A-Z]+$/)) break
|
|
315
|
+
newText += text.charAt(chNoInText - 1)
|
|
316
|
+
}
|
|
317
|
+
newText += " "
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
console.log(newText)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.61",
|
|
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": {
|
package/regex-tester.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const CodexParser = require("./src/CodexParser")
|
|
2
|
+
|
|
3
|
+
const parser = new CodexParser()
|
|
4
|
+
const passage = "jer 9.24 1 cor 1.31 Jd 1"
|
|
5
|
+
let text = `Joel 10:13 The passages Luke 2:32 and Lk 1:23 that we are looking at tonight 1 Cor 12:34 2 Cor 3:4 are found Jude 6, in Jude 5, Genesis 2:1 - 3:19, 1 John 3:16-17, 1 Peter 1:1, and Romans 10:13, 15, 17. Please turn in your Bibles. Ps 109:4,5,6,8. Isaiah 61.2-3 Mt 5.4
|
|
6
|
+
|
|
7
|
+
Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3
|
|
8
|
+
|
|
9
|
+
Jd. 5
|
|
10
|
+
Jd 6
|
|
11
|
+
|
|
12
|
+
1Cor 12:34 2 Cor 3:4. He 4.12 Re 1.16
|
|
13
|
+
|
|
14
|
+
Leviticus 16:6 He 5.3 He 7.27
|
|
15
|
+
|
|
16
|
+
Hos 10:1-3, 8 and 1 John 2:23
|
|
17
|
+
|
|
18
|
+
exod15.18. 2 Cor 12:23 Malachi 3:32 Hebrews 9:20; 10:29; 13:20 `
|
|
19
|
+
|
|
20
|
+
const philemon = "Phlm 1 Phlm 1:2 Philemon 1:3 Phil 2:3 Phile 7"
|
|
21
|
+
|
|
22
|
+
const ez = "Ezekiel 12:3 Ezek 1:2 Ezk 2:2 Ezra 1:1 Ezr 1:2 Ez 3:4-5"
|
|
23
|
+
|
|
24
|
+
const noSpace = "1pet2.6"
|
|
25
|
+
|
|
26
|
+
parser.regex("1sam1:1").regexParser()
|
|
27
|
+
console.log(parser.getPassages())
|
package/scan-test.js
CHANGED
|
@@ -4,8 +4,20 @@ const util = require("util")
|
|
|
4
4
|
const dump = (item) => {
|
|
5
5
|
console.log(util.inspect(item, { depth: null, colors: true }))
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
let text = `Joel 10:13 The passages Luke 2:32 and Lk 1:23 that we are looking at tonight 1 Cor 12:34 2 Cor 3:4 are found Jude 6, in Jude 5, Genesis 2:1 - 3:19, 1 John 3:16-17, 1 Peter 1:1, and Romans 10:13, 15, 17. Please turn in your Bibles. Ps 109:4,5,6,8. Isaiah 61.2-3 Mt 5.4
|
|
8
|
+
|
|
9
|
+
Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3
|
|
10
|
+
|
|
11
|
+
Jd. 5
|
|
12
|
+
Jd 6
|
|
13
|
+
|
|
14
|
+
1 Cor 12:34 2 Cor 3:4. He 4.12 Re 1.16
|
|
15
|
+
|
|
16
|
+
Leviticus 16:6 He 5.3 He 7.27
|
|
17
|
+
|
|
18
|
+
Hos 10:1-3, 8 and 1 John 2:23
|
|
19
|
+
|
|
20
|
+
exod15.18. 2 Cor 12:23 Malachi 3:32`
|
|
9
21
|
const parser = new BibleParser()
|
|
10
|
-
const result = parser.find(
|
|
22
|
+
const result = parser.find(text)
|
|
11
23
|
dump(result)
|
package/src/CodexParser.js
CHANGED
|
@@ -23,8 +23,15 @@ class CodexParser {
|
|
|
23
23
|
this.crawler = new crawler()
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Sets the options for the crawler and returns the current instance.
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} options - The options to set.
|
|
30
|
+
* @return {Object} The current instance.
|
|
31
|
+
*/
|
|
26
32
|
options(options) {
|
|
27
33
|
this.crawler.set_options(options)
|
|
34
|
+
return this
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
/**
|
|
@@ -71,7 +78,8 @@ class CodexParser {
|
|
|
71
78
|
parse(reference) {
|
|
72
79
|
//TODO: Need to fix chapter ranges when another verse is tacted onto the end of it.
|
|
73
80
|
if (!reference) {
|
|
74
|
-
|
|
81
|
+
this.passages = []
|
|
82
|
+
return this
|
|
75
83
|
}
|
|
76
84
|
this.passages = []
|
|
77
85
|
this.scan(reference)
|
|
@@ -161,19 +169,17 @@ class CodexParser {
|
|
|
161
169
|
if (typeof book !== "string") {
|
|
162
170
|
book = book[0]
|
|
163
171
|
}
|
|
164
|
-
let bookified
|
|
165
|
-
|
|
172
|
+
let bookified = Object.keys(this.abbrevations).find((abbr) => {
|
|
173
|
+
return abbr.toLowerCase() === book.toLowerCase()
|
|
174
|
+
})
|
|
175
|
+
bookified = this.abbrevations[bookified]
|
|
166
176
|
if (!bookified) {
|
|
167
177
|
bookified = this.bible.new.find(
|
|
168
|
-
(b) =>
|
|
169
|
-
b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
|
|
170
|
-
b.toLowerCase().includes(book.toLowerCase())
|
|
178
|
+
(b) => b.toLowerCase() === book.toLowerCase() && b.toLowerCase().includes(book.toLowerCase())
|
|
171
179
|
)
|
|
172
180
|
if (!bookified) {
|
|
173
181
|
bookified = this.bible.old.find(
|
|
174
|
-
(b) =>
|
|
175
|
-
b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
|
|
176
|
-
b.toLowerCase().includes(book.toLowerCase())
|
|
182
|
+
(b) => b.toLowerCase() === book.toLowerCase() && b.toLowerCase().includes(book.toLowerCase())
|
|
177
183
|
)
|
|
178
184
|
}
|
|
179
185
|
}
|
|
@@ -205,311 +211,129 @@ class CodexParser {
|
|
|
205
211
|
.trim()
|
|
206
212
|
}
|
|
207
213
|
find(text) {
|
|
208
|
-
const books = [
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
"
|
|
218
|
-
"Num",
|
|
219
|
-
"Nu",
|
|
220
|
-
"Nm",
|
|
221
|
-
"Nb",
|
|
222
|
-
"Deut",
|
|
223
|
-
"Dt",
|
|
224
|
-
"Josh",
|
|
225
|
-
"Jos",
|
|
226
|
-
"Jsh",
|
|
227
|
-
"Judg",
|
|
228
|
-
"Jdg",
|
|
229
|
-
"Jg",
|
|
230
|
-
"Jdgs",
|
|
231
|
-
"Rth",
|
|
232
|
-
"Ru",
|
|
233
|
-
"Sam",
|
|
234
|
-
"Samuel",
|
|
235
|
-
"Kings",
|
|
236
|
-
"Kgs",
|
|
237
|
-
"Kin",
|
|
238
|
-
"Chron",
|
|
239
|
-
"Chronicles",
|
|
240
|
-
"Ezra",
|
|
241
|
-
"Ezr",
|
|
242
|
-
"Ez",
|
|
243
|
-
"Neh",
|
|
244
|
-
"Ne",
|
|
245
|
-
"Esth",
|
|
246
|
-
"Es",
|
|
247
|
-
"Job",
|
|
248
|
-
"Job",
|
|
249
|
-
"Jb",
|
|
250
|
-
"Pslm",
|
|
251
|
-
"Ps",
|
|
252
|
-
"Psalms",
|
|
253
|
-
"Psa",
|
|
254
|
-
"Psm",
|
|
255
|
-
"Pss",
|
|
256
|
-
"Prov",
|
|
257
|
-
"Pr",
|
|
258
|
-
"Prv",
|
|
259
|
-
"Eccles",
|
|
260
|
-
"Ec",
|
|
261
|
-
"Song",
|
|
262
|
-
"So",
|
|
263
|
-
"Canticles",
|
|
264
|
-
"Song of Songs",
|
|
265
|
-
"SOS",
|
|
266
|
-
"Isa",
|
|
267
|
-
"Is",
|
|
268
|
-
"Jer",
|
|
269
|
-
"Je",
|
|
270
|
-
"Jr",
|
|
271
|
-
"Lam",
|
|
272
|
-
"La",
|
|
273
|
-
"Ezek",
|
|
274
|
-
"Eze",
|
|
275
|
-
"Ezk",
|
|
276
|
-
"Dan",
|
|
277
|
-
"Da",
|
|
278
|
-
"Dn",
|
|
279
|
-
"Hos",
|
|
280
|
-
"Ho",
|
|
281
|
-
"Joel",
|
|
282
|
-
"Joe",
|
|
283
|
-
"Jl",
|
|
284
|
-
"Amos",
|
|
285
|
-
"Am",
|
|
286
|
-
"Obad",
|
|
287
|
-
"Ob",
|
|
288
|
-
"Jnh",
|
|
289
|
-
"Jon",
|
|
290
|
-
"Micah",
|
|
291
|
-
"Mic",
|
|
292
|
-
"Nah",
|
|
293
|
-
"Na",
|
|
294
|
-
"Hab",
|
|
295
|
-
"Zeph",
|
|
296
|
-
"Zep",
|
|
297
|
-
"Zp",
|
|
298
|
-
"Haggai",
|
|
299
|
-
"Hag",
|
|
300
|
-
"Hg",
|
|
301
|
-
"Zech",
|
|
302
|
-
"Zec",
|
|
303
|
-
"Zc",
|
|
304
|
-
"Mal",
|
|
305
|
-
"Mal",
|
|
306
|
-
"Ml",
|
|
307
|
-
"Matt",
|
|
308
|
-
"Mt",
|
|
309
|
-
"Mrk",
|
|
310
|
-
"Mk",
|
|
311
|
-
"Mr",
|
|
312
|
-
"Luk",
|
|
313
|
-
"Lk",
|
|
314
|
-
"John",
|
|
315
|
-
"Jn",
|
|
316
|
-
"Jhn",
|
|
317
|
-
"Acts",
|
|
318
|
-
"Ac",
|
|
319
|
-
"Rom",
|
|
320
|
-
"Ro",
|
|
321
|
-
"Rm",
|
|
322
|
-
"Co",
|
|
323
|
-
"Cor",
|
|
324
|
-
"Corinthians",
|
|
325
|
-
"Gal",
|
|
326
|
-
"Ga",
|
|
327
|
-
"Ephes",
|
|
328
|
-
"Eph",
|
|
329
|
-
"Phil",
|
|
330
|
-
"Php",
|
|
331
|
-
"Col",
|
|
332
|
-
"Col",
|
|
333
|
-
"Th",
|
|
334
|
-
"Thes",
|
|
335
|
-
"Thess",
|
|
336
|
-
"Thessalonians",
|
|
337
|
-
"Ti",
|
|
338
|
-
"Tim",
|
|
339
|
-
"Timothy",
|
|
340
|
-
"Titus",
|
|
341
|
-
"Tit",
|
|
342
|
-
"Philem",
|
|
343
|
-
"Phm",
|
|
344
|
-
"Hebrews",
|
|
345
|
-
"Heb",
|
|
346
|
-
"He",
|
|
347
|
-
"James",
|
|
348
|
-
"Jas",
|
|
349
|
-
"Jm",
|
|
350
|
-
"Pe",
|
|
351
|
-
"Pet",
|
|
352
|
-
"Pt",
|
|
353
|
-
"Peter",
|
|
354
|
-
"Jn",
|
|
355
|
-
"Jo",
|
|
356
|
-
"Joh",
|
|
357
|
-
"Jhn",
|
|
358
|
-
"John",
|
|
359
|
-
"Jude",
|
|
360
|
-
"Jd",
|
|
361
|
-
"Jud",
|
|
362
|
-
"Jud",
|
|
363
|
-
"Rev",
|
|
364
|
-
"The Revelation",
|
|
365
|
-
"Genesis",
|
|
366
|
-
"Exodus",
|
|
367
|
-
"Leviticus",
|
|
368
|
-
"Numbers",
|
|
369
|
-
"Deuteronomy",
|
|
370
|
-
"Joshua",
|
|
371
|
-
"Judges",
|
|
372
|
-
"Ruth",
|
|
373
|
-
"Samuel",
|
|
374
|
-
"Kings",
|
|
375
|
-
"Chronicles",
|
|
376
|
-
"Ezra",
|
|
377
|
-
"Nehemiah",
|
|
378
|
-
"Esther",
|
|
379
|
-
"Job",
|
|
380
|
-
"Psalms",
|
|
381
|
-
"Psalm",
|
|
382
|
-
"Proverbs",
|
|
383
|
-
"Ecclesiastes",
|
|
384
|
-
"Song of Solomon",
|
|
385
|
-
"Isaiah",
|
|
386
|
-
"Jeremiah",
|
|
387
|
-
"Lamentations",
|
|
388
|
-
"Ezekiel",
|
|
389
|
-
"Daniel",
|
|
390
|
-
"Hosea",
|
|
391
|
-
"Joel",
|
|
392
|
-
"Amos",
|
|
393
|
-
"Obadiah",
|
|
394
|
-
"Jonah",
|
|
395
|
-
"Micah",
|
|
396
|
-
"Nahum",
|
|
397
|
-
"Habakkuk",
|
|
398
|
-
"Zephaniah",
|
|
399
|
-
"Haggai",
|
|
400
|
-
"Zechariah",
|
|
401
|
-
"Malachi",
|
|
402
|
-
"Matthew",
|
|
403
|
-
"Mark",
|
|
404
|
-
"Luke",
|
|
405
|
-
"John",
|
|
406
|
-
"Acts",
|
|
407
|
-
"Romans",
|
|
408
|
-
"Corinthians",
|
|
409
|
-
"Galatians",
|
|
410
|
-
"Ephesians",
|
|
411
|
-
"Philippians",
|
|
412
|
-
"Colossians",
|
|
413
|
-
"Thessalonians",
|
|
414
|
-
"Timothy",
|
|
415
|
-
"Titus",
|
|
416
|
-
"Philemon",
|
|
417
|
-
"Hebrews",
|
|
418
|
-
"James",
|
|
419
|
-
"Peter",
|
|
420
|
-
"John",
|
|
421
|
-
"Revelation",
|
|
422
|
-
"Re",
|
|
423
|
-
"Ap",
|
|
424
|
-
"Jd.",
|
|
425
|
-
"Heb.",
|
|
426
|
-
]
|
|
214
|
+
const books = [...this.bible.old, ...this.bible.new]
|
|
215
|
+
const found = []
|
|
216
|
+
const passages = []
|
|
217
|
+
for (let i = 0; i < books.length; i++) {
|
|
218
|
+
const book = books[i].toLowerCase()
|
|
219
|
+
const index = text.toLowerCase().indexOf(book)
|
|
220
|
+
// Checks to see if the previous character is a colon. If it is, skip.
|
|
221
|
+
// This makes sure that if you have a case like Genesis 1:1 John 1:1, the code knows that
|
|
222
|
+
// the book cannot be 1 John.
|
|
223
|
+
if (text[index - 1] && text[index - 1].includes(":")) continue
|
|
427
224
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
"Pe",
|
|
449
|
-
"Pet",
|
|
450
|
-
"Pt",
|
|
451
|
-
"John",
|
|
452
|
-
"Jn",
|
|
453
|
-
"Jhn",
|
|
454
|
-
]
|
|
225
|
+
// Get the book and chapter
|
|
226
|
+
if (index > -1) {
|
|
227
|
+
const bookEndIndex = index + book.length - 1
|
|
228
|
+
const passage = {
|
|
229
|
+
book: text.substring(index, bookEndIndex + 1),
|
|
230
|
+
}
|
|
231
|
+
let chapter = 0
|
|
232
|
+
let chapterStartIndex = null
|
|
233
|
+
let chapterEndIndex = null
|
|
234
|
+
let j = bookEndIndex + 1
|
|
235
|
+
while (j < text.length) {
|
|
236
|
+
const match = text.substring(j).match(/^\s*(\d+)/)
|
|
237
|
+
if (match) {
|
|
238
|
+
chapter = match[1]
|
|
239
|
+
chapterStartIndex = j
|
|
240
|
+
chapterEndIndex = j + match[0].length
|
|
241
|
+
break
|
|
242
|
+
}
|
|
243
|
+
j++
|
|
244
|
+
}
|
|
455
245
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
// add the book name with . at the end as this seems to be added sometimes, at least to the shortened forms
|
|
463
|
-
const length = books.length
|
|
464
|
-
for (let b = 0; b < length; b++) {
|
|
465
|
-
books.push(books[b] + ".")
|
|
466
|
-
}
|
|
246
|
+
let verseIndex = chapterEndIndex + 1
|
|
247
|
+
let verseStartIndex = null
|
|
248
|
+
let verseEndIndex = null
|
|
249
|
+
let verse
|
|
250
|
+
while (verseIndex < text.length) {
|
|
251
|
+
const match = text.substring(verseIndex).match(/^\s*?(\d+)[^a-zA-Z]*/)
|
|
467
252
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
for (let b = 0; b < books.length; b++) {
|
|
473
|
-
const book = books[b]
|
|
474
|
-
let chNoInText = 0
|
|
475
|
-
while (chNoInText < text.length) {
|
|
476
|
-
let j = text.indexOf(book, chNoInText)
|
|
477
|
-
if (j < 0) break
|
|
478
|
-
if (j + book.length < text.length && !text.charAt(j + book.length).match(/^[a-z]+$/)) {
|
|
479
|
-
booksAt.push([book, j])
|
|
480
|
-
let replacement = book
|
|
481
|
-
for (let k = 0; k < book.length; k++) {
|
|
482
|
-
replacement = replacement.replace(book.charAt(k), "X")
|
|
253
|
+
if (match) {
|
|
254
|
+
verseStartIndex = verseIndex
|
|
255
|
+
verseEndIndex = verseIndex + match[0].length
|
|
256
|
+
break
|
|
483
257
|
}
|
|
484
|
-
|
|
258
|
+
verseIndex++
|
|
485
259
|
}
|
|
486
|
-
|
|
260
|
+
verse = parseInt(text.substring(verseStartIndex, verseEndIndex))
|
|
261
|
+
|
|
262
|
+
if (chapter > 0) passage.chapter = chapter
|
|
263
|
+
if (verse > 0) passage.verse = verse
|
|
264
|
+
|
|
265
|
+
passage.index = {
|
|
266
|
+
start: index,
|
|
267
|
+
}
|
|
268
|
+
found.push(passage)
|
|
487
269
|
}
|
|
488
270
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
271
|
+
return found
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
regex(text) {
|
|
275
|
+
this.found = text.match(this.scripturesRegex)
|
|
276
|
+
console.log(this.found)
|
|
277
|
+
return this
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
regexParser() {
|
|
281
|
+
this.passages = []
|
|
282
|
+
for (let i = 0; i < this.found.length; i++) {
|
|
283
|
+
let verse, chapter
|
|
284
|
+
const hasChapterRange = this.found[i].match(/(?<=-\s?)\b\d+[.:].+\b/)
|
|
285
|
+
const book = this.found[i].match(this.bookRegex)
|
|
286
|
+
console.log("Book that is found is ", book, this.bookify(book))
|
|
287
|
+
if (book === null) continue
|
|
288
|
+
chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
|
|
289
|
+
|
|
290
|
+
if (Array.isArray(chapter)) {
|
|
291
|
+
chapter = chapter[0]
|
|
292
|
+
}
|
|
293
|
+
if (
|
|
294
|
+
this.bookify(book).toLowerCase() === "jude" ||
|
|
295
|
+
this.bookify(book).toLowerCase() === "philemon" ||
|
|
296
|
+
this.bookify(book).toLowerCase() === "obadiah" ||
|
|
297
|
+
this.bookify(book).toLowerCase() === "2 john" ||
|
|
298
|
+
this.bookify(book).toLowerCase() === "3 john"
|
|
299
|
+
) {
|
|
300
|
+
verse = this.found[i].split(" ")[1]
|
|
301
|
+
chapter = "1"
|
|
302
|
+
} else {
|
|
303
|
+
if (this.found[i].match(this.verseRegex))
|
|
304
|
+
verse = this.found[i].match(this.verseRegex)[0].replace(/[:.]/, "").trim()
|
|
500
305
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
for (let i = 0; i < 100; i++) {
|
|
504
|
-
chNoInText++
|
|
505
|
-
const nextCh = text.charAt(chNoInText)
|
|
506
|
-
//test whether are at the end of the chapter(s) and verse(s)
|
|
507
|
-
if (nextCh.match(/^[a-z]+$/)) break
|
|
508
|
-
if (nextCh.match(/^[A-Z]+$/)) break
|
|
509
|
-
newText += text.charAt(chNoInText - 1)
|
|
306
|
+
if (!verse && this.found[i].match(/\d+/)) {
|
|
307
|
+
chapter = this.found[i].match(/\d+/)[0]
|
|
510
308
|
}
|
|
309
|
+
|
|
310
|
+
const passage = {
|
|
311
|
+
original: this.found[i].replace(/([.,])\1*$/, "").trim(),
|
|
312
|
+
book: this.bookify(book),
|
|
313
|
+
chapter: chapter,
|
|
314
|
+
verses: verse ?? [],
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (hasChapterRange) {
|
|
318
|
+
passage.to = {
|
|
319
|
+
book: passage.book,
|
|
320
|
+
chapter: hasChapterRange[0].match(this.chapterRegex),
|
|
321
|
+
verses: hasChapterRange[0].match(this.verseRegex)[0].replace(/[:.]/, "").trim(),
|
|
322
|
+
}
|
|
323
|
+
passage.to.verses = passage.to.verses.split(/,/).filter(Boolean)
|
|
324
|
+
passage.to.testament = this.bible.old.includes(passage.to.book) ? "old" : "new"
|
|
325
|
+
}
|
|
326
|
+
passage.verses =
|
|
327
|
+
typeof passage.verses !== "object"
|
|
328
|
+
? passage.verses.split(/,/).filter(Boolean)
|
|
329
|
+
: passage.verses.filter((item) => item.trim())
|
|
330
|
+
passage.testament = this.bible.old.includes(passage.book) ? "old" : "new"
|
|
331
|
+
passage.scripture = this.scripturize(passage)
|
|
332
|
+
this.passages.push(passage)
|
|
511
333
|
}
|
|
512
|
-
|
|
334
|
+
|
|
335
|
+
this.found = []
|
|
336
|
+
return this
|
|
513
337
|
}
|
|
514
338
|
}
|
|
515
339
|
|
package/src/abbr.js
CHANGED
|
@@ -26,23 +26,33 @@ const abbrevations = {
|
|
|
26
26
|
Rth: "Ruth",
|
|
27
27
|
Ru: "Ruth",
|
|
28
28
|
"1Sam": "1 Samuel",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"1
|
|
33
|
-
"1
|
|
34
|
-
"1
|
|
35
|
-
"1
|
|
29
|
+
"1sam": "1 Samuel",
|
|
30
|
+
"1SA": "1 Samuel",
|
|
31
|
+
"1sa": "1 Samuel",
|
|
32
|
+
"1 SAM": "1 Samuel",
|
|
33
|
+
"1 sam": "1 Samuel",
|
|
34
|
+
"1 sm": "1 Samuel",
|
|
35
|
+
"1 sa": "1 Samuel",
|
|
36
|
+
"1 s": "1 Samuel",
|
|
36
37
|
"2 Sam": "2 Samuel",
|
|
37
|
-
"2
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
38
|
+
"2 sam": "2 Samuel",
|
|
39
|
+
"2SA": "2 Samuel",
|
|
40
|
+
"2sa": "2 Samuel",
|
|
41
|
+
"2 SAM": "2 Samuel",
|
|
42
|
+
"2 sam": "2 Samuel",
|
|
43
|
+
"2 sm": "2 Samuel",
|
|
44
|
+
"2 sa": "2 Samuel",
|
|
45
|
+
"2 s": "2 Samuel",
|
|
46
|
+
"II SAM": "2 Samuel",
|
|
47
|
+
"ii sam": "2 Samuel",
|
|
48
|
+
"II SA": "2 Samuel",
|
|
49
|
+
"ii sa": "2 Samuel",
|
|
50
|
+
"2SAM": "2 Samuel",
|
|
51
|
+
"2sam": "2 Samuel",
|
|
52
|
+
"2SM": "2 Samuel",
|
|
53
|
+
"2sm": "2 Samuel",
|
|
54
|
+
"2SA": "2 Samuel",
|
|
55
|
+
"2sa": "2 Samuel",
|
|
46
56
|
"1Kgs": "1 Kings",
|
|
47
57
|
"1 Kgs": "1 Kings",
|
|
48
58
|
"1Kgs": "1 Kings",
|
|
@@ -81,6 +91,7 @@ const abbrevations = {
|
|
|
81
91
|
"II Ch": "2 Chronicles",
|
|
82
92
|
Ezra: "Ezra",
|
|
83
93
|
Ezr: "Ezra",
|
|
94
|
+
Ez: "Ezra",
|
|
84
95
|
Neh: "Nehemiah",
|
|
85
96
|
Ne: "Nehemiah",
|
|
86
97
|
Esth: "Esther",
|
|
@@ -179,11 +190,18 @@ const abbrevations = {
|
|
|
179
190
|
"2Co": "2 Corinthians",
|
|
180
191
|
"2Cor": "2 Corinthians",
|
|
181
192
|
"2 Cor": "2 Corinthians",
|
|
193
|
+
"1cor": "1 Corinthians",
|
|
194
|
+
"1 cor": "1 Corinthians",
|
|
195
|
+
"1 co": "1 Corinthians",
|
|
196
|
+
"1co": "1 Corinthians",
|
|
197
|
+
"2cor": "2 Corinthians",
|
|
198
|
+
"2 cor": "2 Corinthians",
|
|
199
|
+
"2 co": "2 Corinthians",
|
|
200
|
+
"2co": "2 Corinthians",
|
|
182
201
|
Gal: "Galatians",
|
|
183
202
|
Ga: "Galatians",
|
|
184
203
|
Eph: "Ephesians",
|
|
185
204
|
Ephes: "Ephesians",
|
|
186
|
-
Phil: "Philippians",
|
|
187
205
|
Php: "Philippians",
|
|
188
206
|
Pp: "Philippians",
|
|
189
207
|
Col: "Colossians",
|
|
@@ -213,8 +231,6 @@ const abbrevations = {
|
|
|
213
231
|
Ti: "Titus",
|
|
214
232
|
Phlm: "Philemon",
|
|
215
233
|
Phm: "Philemon",
|
|
216
|
-
Phile: "Philemon",
|
|
217
|
-
Ph: "Philemon",
|
|
218
234
|
Hebr: "Hebrews",
|
|
219
235
|
Heb: "Hebrews",
|
|
220
236
|
He: "Hebrews",
|
|
@@ -222,7 +238,8 @@ const abbrevations = {
|
|
|
222
238
|
Jm: "James",
|
|
223
239
|
James: "James",
|
|
224
240
|
"1Pet": "1 Peter",
|
|
225
|
-
"
|
|
241
|
+
"1pe": "1 Peter",
|
|
242
|
+
"1 pe": "1 Peter",
|
|
226
243
|
"1 Pe": "1 Peter",
|
|
227
244
|
"1Pet": "1 Peter",
|
|
228
245
|
"2Pet": "2 Peter",
|
|
@@ -255,14 +272,9 @@ const abbrevations = {
|
|
|
255
272
|
Re: "Revelation",
|
|
256
273
|
Mt: "Matthew",
|
|
257
274
|
Mc: "Mark",
|
|
258
|
-
L: "Luke",
|
|
259
|
-
J: "John",
|
|
260
275
|
Act: "Acts",
|
|
261
|
-
R: "Romans",
|
|
262
276
|
"1K": "1 Corinthians",
|
|
263
277
|
"2K": "2 Corinthians",
|
|
264
|
-
G: "Galatians",
|
|
265
|
-
Ph: "Philippians",
|
|
266
278
|
Kol: "Colossians",
|
|
267
279
|
"1Th": "1 Thessalonians",
|
|
268
280
|
"2Th": "2 Thessalonians",
|
|
@@ -270,7 +282,6 @@ const abbrevations = {
|
|
|
270
282
|
"2T": "2 Timothy",
|
|
271
283
|
Tt: "Titus",
|
|
272
284
|
Phm: "Philemon",
|
|
273
|
-
H: "Hebrews",
|
|
274
285
|
Jc: "James",
|
|
275
286
|
"1P": "1 Peter",
|
|
276
287
|
"2P": "2 Peter",
|
package/src/regex.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
const bookRegex =
|
|
2
|
-
/((?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s)?(Gen|Gn|Exo|Ex|Exod|Lev|Lv|Num|Nu|Nm|Nb|Deut|Dt|Josh|Jos|Jsh|Judg|Jdg|Jg|Jdgs|Rth|Ru|Sam|Samuel|Kings|Kgs|Chron|Chronicles|Ezra|Ezr|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
2
|
+
/((?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s?)?(Gen|Gn|Exo|Ex|Exod|Lev|Lv|Num|Nu|Nm|Nb|Deut|Dt|Josh|Jos|Jsh|Judg|Jdg|Jg|Jdgs|Rth|Ru|Sam|Samuel|Kings|Kgs|Chron|Chronicles|Ezra|Ezr|Neh|Ne|Esth|Job|Job|Jb|Pslm|Ps|Psalms|Psa|Psm|Pss|Prov|Pr|Prv|Eccles|Ec|Song|So|Canticles|Song of Songs|SOS|Isa|Is|Jer|Je|Jr|Lam|La|Ezek|Eze|Ezk|Dan|Da|Dn|Hos|Ho|Joel|Joe|Jl|Amos|Am|Obad|Ob|Jnh|Jon|Micah|Mic|Nah|Na|Hab|Zeph|Zep|Zp|Haggai|Hag|Hg|Zech|Zec|Zc|Mal|Mal|Ml|Matt|Mrk|Mk|Luk|Lk|John|Jn|Jhn|Acts|Ac|Rom|Ro|Rm|Co|Cor|Corinthians|Gal|Ga|Ephes|Eph|Php|Col|Col|Thes|Thess|Thessalonians|Ti|Tim|Timothy|Titus|Tit|Philem|Phm|Phlm|Phile|Hebrews|Heb|He|James|Jas|Jm|Pe|Pet|Pt|Peter|Jn|Jo|Joh|Jhn|John|Jude|Jd|Jud|Jud|Rev|The Revelation|Genesis|Exodus|Leviticus|Numbers|Deuteronomy|Joshua|Judges|Ruth|Samuel|Kings|Chronicles|Ezra|Nehemiah|Esther|Job|Psalms|Psalm|Proverbs|Ecclesiastes|Song of Solomon|Isaiah|Jeremiah|Lamentations|Ezekiel|Daniel|Hosea|Joel|Amos|Obadiah|Jonah|Micah|Nahum|Habakkuk|Zephaniah|Haggai|Zechariah|Malachi|Matthew|Mark|Luke|John|Acts|Romans|Corinthians|Galatians|Ephesians|Philippians|Phil|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|John|Revelation|Re|Ap))/gim
|
|
3
|
+
const EzraAbbrv = /(Ez)(?![a-zA-Z])/gim
|
|
4
|
+
const chapterRegex = /(\d+)(?=[:.])/gim
|
|
5
|
+
const verseRegex = /(?<=[:.])[\d: .\-]+(?:, ?[\d\-]+)*(?<![ .])/gim
|
|
5
6
|
const chapterRange = /.?\s?(?:[-—–])\s?/gm
|
|
6
7
|
const chapterRangeVerseRegex = /(?:.\d+)?/gm
|
|
7
|
-
const chapterVerseRange =
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const chapterVerseRange =
|
|
9
|
+
/(.?\s?\d+((?:[:.]\d+)?(\s?[-–—]\s?)?(?:\d+)(?:(,\s?\d+)*)?\S([:.]?\d+)?(,?\s?\d+[–—-]\s?\d+,?\d+)?)?(?:[:.]\d+)?(?:[abcde])?(?:,\d+)*(?:[-–—]\d?\s?)?)(?:[:.]\d+[–-—]\s?\d+,?\s?\d+)?/gim
|
|
10
|
+
const scripturesRegex = new RegExp(`(${bookRegex.source}|${EzraAbbrv.source})(${chapterVerseRange.source})`, "gmi")
|
|
11
|
+
module.exports.bookRegex = new RegExp(`(${bookRegex.source}|${EzraAbbrv.source})`, "gmi") // bookRegex
|
|
10
12
|
module.exports.chapterRegex = chapterRegex
|
|
11
13
|
module.exports.scripturesRegex = scripturesRegex
|
|
12
14
|
module.exports.verseRegex = verseRegex
|
|
@@ -4,8 +4,9 @@ const util = require("util")
|
|
|
4
4
|
const dump = (item) => {
|
|
5
5
|
console.log(util.inspect(item, { depth: null, colors: true }))
|
|
6
6
|
}
|
|
7
|
-
const string = "
|
|
8
|
-
console.log(string)
|
|
7
|
+
const string = "Malachi 3:32"
|
|
9
8
|
const parser = new BibleParser()
|
|
9
|
+
parser.options({ invalid_passage_strategy: "include", invalid_sequence_strategy: "include" })
|
|
10
|
+
console.log(parser)
|
|
10
11
|
const result = parser.parse(string)
|
|
11
12
|
dump(result.getPassages())
|