codexparser 0.0.64 → 0.0.67

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.
@@ -9,14 +9,11 @@ const parser = new CodexParser({
9
9
  invalid_sequence_strategy: "include",
10
10
  invalid_passage_strategy: "include",
11
11
  })
12
- const text =
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"
12
+ const 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`
14
13
  const single = "Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3"
15
14
  const jd = "Jd. 5"
16
15
  const cor = "1 Cor 12:4 2 Cor 3:4"
17
16
  const noSpace = "Re13.8 "
18
17
  const ezra = " Ez 1:3"
19
18
  const passages = parser.parse(text + single + jd + cor + noSpace + ezra)
20
- passages.getPassages().forEach((passage) => {
21
- dump(passage)
22
- })
19
+ dump(passages.getPassages())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.0.64",
3
+ "version": "0.0.67",
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": {
@@ -89,56 +89,46 @@ class CodexParser {
89
89
  }
90
90
  this.passages = []
91
91
  this.scan(reference)
92
- const books = []
93
92
  for (let i = 0; i < this.found.length; i++) {
94
- books.push(this.found[i].start.b)
95
- }
96
- const uniqueBooks = [...new Set(books)]
97
-
98
- const booksWithResults = []
99
- for (const book of uniqueBooks) {
100
- const found = this.found.filter((passage) => passage.start.b === book)
101
- booksWithResults.push(found)
102
- }
103
-
104
- for (let i = 0; i < booksWithResults.length; i++) {
105
- const results = booksWithResults[i]
106
- for (let j = 0; j < results.length; j++) {
107
- const result = results[j]
108
-
109
- const passage = {
110
- book: this.bookify(result.start.b),
111
- chapter: result.start.c,
112
- verses: this.versify(result),
113
- type: result.type,
114
- }
115
- passage.testament = this.bible.old.includes(passage.book) ? "old" : "new"
116
- let next = results[j + 1]
117
- while (next && next.type === "integer" && next.end.c === result.start.c) {
118
- passage.verses.push(next.start.v)
119
- if (next.end.v !== next.start.v) passage.verses.push(next.end.v)
120
- passage.subType = next.type
121
- j++
122
- next = results[j + 1]
123
- }
124
- if (passage.type === "range") {
125
- if (result.start.c !== result.end.c) {
126
- passage.verses = [result.start.v]
127
- passage.to = {
128
- book: this.bookify(result.end.b),
129
- chapter: result.end.c,
130
- verses: result.end.v,
131
- }
93
+ const result = this.found[i]
94
+ const passage = {
95
+ book: this.bookify(result.start.b),
96
+ chapter: result.start.c,
97
+ verses: this.versify(result),
98
+ type: result.type,
99
+ }
100
+ passage.testament = this.bible.old.includes(passage.book) ? "old" : "new"
101
+ let next = this.found[i + 1]
102
+ while (next && next.type === "integer" && next.start.b === result.end.b && next.end.c === result.start.c) {
103
+ passage.verses.push(next.start.v)
104
+ if (next.end.v !== next.start.v) passage.verses.push(next.end.v)
105
+ passage.subType = next.type
106
+ i++
107
+ next = this.found[i + 1]
108
+ }
109
+ if (passage.type === "range") {
110
+ if (result.start.c !== result.end.c) {
111
+ passage.verses = [result.start.v]
112
+ passage.to = {
113
+ book: this.bookify(result.end.b),
114
+ chapter: result.end.c,
115
+ verses: result.end.v,
132
116
  }
133
117
  }
134
- passage.original = result.osis
135
- passage.scripture = this.scripturize(passage)
136
- passage.indices = result.indices
137
- passage.entities = result.entities
138
- this.passages.push(passage)
139
118
  }
119
+ passage.original = result.osis
120
+ passage.scripture = this.scripturize(passage)
121
+ passage.indices = result.indices
122
+ passage.entities = result.entities
123
+ if (passage.entities[0].translations) {
124
+ passage.version = {
125
+ name: passage.entities[0].translations[0].translation,
126
+ alias: passage.entities[0].translations[0].alias,
127
+ abbreviation: passage.entities[0].translations[0].osis,
128
+ }
129
+ }
130
+ this.passages.push(passage)
140
131
  }
141
- this.passages.sort((a, b) => a.chapter - b.chapter)
142
132
  this.found = []
143
133
  return this
144
134
  }
@@ -6,6 +6,10 @@ const dump = (item) => {
6
6
  }
7
7
  const string = "Malachi 3:32"
8
8
  const parser = new BibleParser()
9
- parser.options({ invalid_passage_strategy: "include", invalid_sequence_strategy: "include" })
10
- const result = parser.parse("Philippians 4:18")
9
+ parser.options({
10
+ invalid_passage_strategy: "include",
11
+ invalid_sequence_strategy: "include",
12
+ single_chapter_1_strategy: "verse",
13
+ })
14
+ const result = parser.parse("Ex 9.16 LXX")
11
15
  dump(result.getPassages())