codexparser 0.0.54 → 0.0.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.
@@ -5,14 +5,17 @@ const dump = (item) => {
5
5
  console.log(util.inspect(item, { depth: null, colors: true }))
6
6
  }
7
7
 
8
- const parser = new CodexParser()
8
+ const parser = new CodexParser({
9
+ invalid_sequence_strategy: "include",
10
+ invalid_passage_strategy: "include",
11
+ })
9
12
  const text =
10
13
  "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"
11
14
  const single = "Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3"
12
15
  const jd = "Jd. 5"
13
16
  const cor = "1 Cor 12:4 2 Cor 3:4"
14
17
  const noSpace = "Re13.8"
15
- const passages = parser.parse(text)
18
+ const passages = parser.parse(text + single + jd + cor + noSpace)
16
19
  passages.getPassages().forEach((passage) => {
17
20
  dump(passage)
18
21
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.0.54",
3
+ "version": "0.0.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": {
@@ -97,6 +97,7 @@ class CodexParser {
97
97
  verses: this.versify(result),
98
98
  type: result.type,
99
99
  }
100
+ passage.testament = this.bible.old.includes(passage.book) ? "old" : "new"
100
101
  let next = results[j + 1]
101
102
  while (next && next.type === "integer" && next.end.c === result.start.c) {
102
103
  passage.verses.push(next.start.v)
@@ -131,23 +132,22 @@ class CodexParser {
131
132
  }
132
133
 
133
134
  versify(passage) {
134
- const singleBooks = ["Obadiah", "Philemon", "2 John", "3 John", "Jude"]
135
- if (passage.start.b && singleBooks.includes(passage.start.b)) {
136
- return [passage.start.v + "-" + passage.end.v]
137
- } else {
138
- if (passage.start.v !== passage.end.v) {
139
- if (passage.type === "range") {
140
- return [`${passage.start.v}-${passage.end.v}`]
141
- } else {
135
+ if (passage.start.v !== passage.end.v) {
136
+ if (passage.type === "range") {
137
+ return [`${passage.start.v}-${passage.end.v}`]
138
+ } else {
139
+ if (passage.type !== "bc") {
142
140
  const verses = []
143
141
  for (let i = passage.start.v; i <= passage.end.v; i++) {
144
142
  verses.push(i)
145
143
  }
146
144
  return verses
145
+ } else {
146
+ return [passage.start.v + "-" + passage.end.v]
147
147
  }
148
- } else {
149
- return [passage.start.v]
150
148
  }
149
+ } else {
150
+ return [passage.start.v]
151
151
  }
152
152
  }
153
153
 
@@ -4,7 +4,7 @@ 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 = "Joel 4:13 Mark 4:29 Revelation 14:15,18,19"
7
+ const string = "Gen 1 Jd1 Ps 119:2,4,6,8,19"
8
8
  const parser = new BibleParser()
9
9
  const result = parser.parse(string)
10
10
  dump(result.getPassages())