codexparser 0.1.96 → 0.1.97
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 +3 -3
- package/package.json +1 -1
- package/src/CodexParser.js +30 -27
package/.trunk/trunk.yaml
CHANGED
|
@@ -7,7 +7,7 @@ cli:
|
|
|
7
7
|
plugins:
|
|
8
8
|
sources:
|
|
9
9
|
- id: trunk
|
|
10
|
-
ref: v1.7.
|
|
10
|
+
ref: v1.7.2
|
|
11
11
|
uri: https://github.com/trunk-io/plugins
|
|
12
12
|
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
|
|
13
13
|
runtimes:
|
|
@@ -17,10 +17,10 @@ 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.
|
|
20
|
+
- checkov@3.2.464
|
|
21
21
|
- git-diff-check
|
|
22
22
|
- markdownlint@0.45.0
|
|
23
|
-
- osv-scanner@2.
|
|
23
|
+
- osv-scanner@2.2.1
|
|
24
24
|
- prettier@3.6.2
|
|
25
25
|
- trufflehog@3.90.5
|
|
26
26
|
actions:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.97",
|
|
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/src/CodexParser.js
CHANGED
|
@@ -1141,6 +1141,11 @@ class CodexParser {
|
|
|
1141
1141
|
throw new Error("Passages must be from the same book to join.")
|
|
1142
1142
|
}
|
|
1143
1143
|
|
|
1144
|
+
const versions = new Set(passages.map((p) => p.version.abbreviation))
|
|
1145
|
+
if (versions.size > 1) {
|
|
1146
|
+
throw new Error("Cannot combine passages from different versions.")
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1144
1149
|
const combined = {
|
|
1145
1150
|
...passages[0],
|
|
1146
1151
|
verses: [],
|
|
@@ -1160,35 +1165,30 @@ class CodexParser {
|
|
|
1160
1165
|
|
|
1161
1166
|
passages.forEach((passage) => {
|
|
1162
1167
|
passage.passages.forEach((p) => {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
if (
|
|
1166
|
-
|
|
1167
|
-
normChapter = c
|
|
1168
|
-
normVerse = v
|
|
1169
|
-
}
|
|
1170
|
-
if (!chapterVerses[normChapter]) {
|
|
1171
|
-
chapterVerses[normChapter] = new Set()
|
|
1168
|
+
const chapter = p.chapter
|
|
1169
|
+
const verse = p.verse
|
|
1170
|
+
if (!chapterVerses[chapter]) {
|
|
1171
|
+
chapterVerses[chapter] = new Set()
|
|
1172
1172
|
}
|
|
1173
|
-
chapterVerses[
|
|
1173
|
+
chapterVerses[chapter].add(verse)
|
|
1174
1174
|
combined.passages.push({
|
|
1175
1175
|
book: p.book,
|
|
1176
|
-
chapter:
|
|
1177
|
-
verse:
|
|
1176
|
+
chapter: p.chapter,
|
|
1177
|
+
verse: p.verse,
|
|
1178
1178
|
versification: p.versification,
|
|
1179
1179
|
})
|
|
1180
1180
|
|
|
1181
|
-
if (firstChapter === null ||
|
|
1182
|
-
firstChapter =
|
|
1183
|
-
firstVerse =
|
|
1184
|
-
} else if (
|
|
1185
|
-
firstVerse =
|
|
1181
|
+
if (firstChapter === null || chapter < firstChapter) {
|
|
1182
|
+
firstChapter = chapter
|
|
1183
|
+
firstVerse = verse
|
|
1184
|
+
} else if (chapter === firstChapter && (firstVerse === null || verse < firstVerse)) {
|
|
1185
|
+
firstVerse = verse
|
|
1186
1186
|
}
|
|
1187
|
-
if (lastChapter === null ||
|
|
1188
|
-
lastChapter =
|
|
1189
|
-
lastVerse =
|
|
1190
|
-
} else if (
|
|
1191
|
-
lastVerse =
|
|
1187
|
+
if (lastChapter === null || chapter > lastChapter) {
|
|
1188
|
+
lastChapter = chapter
|
|
1189
|
+
lastVerse = verse
|
|
1190
|
+
} else if (chapter === lastChapter && (lastVerse === null || verse > lastVerse)) {
|
|
1191
|
+
lastVerse = verse
|
|
1192
1192
|
}
|
|
1193
1193
|
})
|
|
1194
1194
|
})
|
|
@@ -1272,18 +1272,21 @@ class CodexParser {
|
|
|
1272
1272
|
delete combined.to
|
|
1273
1273
|
}
|
|
1274
1274
|
|
|
1275
|
-
//
|
|
1276
|
-
combined.version =
|
|
1275
|
+
// Respect the common version
|
|
1276
|
+
combined.version = passages[0].version
|
|
1277
1277
|
|
|
1278
|
-
// Set abbr
|
|
1278
|
+
// Set abbr with version suffix if not ENG
|
|
1279
1279
|
const sblEntry = Object.entries(this.sblAbbreviations).find(
|
|
1280
1280
|
([key]) => key.toLowerCase() === combined.book.toLowerCase()
|
|
1281
1281
|
)
|
|
1282
|
+
const suffix = combined.version.abbreviation === "eng" ? "" : ` ${combined.version.value}`
|
|
1282
1283
|
if (sblEntry) {
|
|
1283
1284
|
const { value, abbr } = sblEntry[1]
|
|
1284
|
-
combined.abbr = abbr
|
|
1285
|
+
combined.abbr = abbr
|
|
1286
|
+
? `${value}. ${combined.scripture.cv}${suffix}`
|
|
1287
|
+
: `${value} ${combined.scripture.cv}${suffix}`
|
|
1285
1288
|
} else {
|
|
1286
|
-
combined.abbr = `${combined.book} ${combined.scripture.cv}`
|
|
1289
|
+
combined.abbr = `${combined.book} ${combined.scripture.cv}${suffix}`
|
|
1287
1290
|
}
|
|
1288
1291
|
|
|
1289
1292
|
const self = this
|