add support for set of verses in a specific chapter
This commit is contained in:
parent
c43861ddfe
commit
2b3549754b
|
|
@ -15,8 +15,8 @@ Read the Word of God from your terminal
|
|||
Individual book
|
||||
<Book>:<Chapter>
|
||||
Individual chapter of a book
|
||||
<Book>:<Chapter>:<Verse>
|
||||
Individual verse of a specific chapter of a book
|
||||
<Book>:<Chapter>:<Verse>[,<Verse>]...
|
||||
Individual verse(s) of a specific chapter of a book
|
||||
<Book>:<Chapter>-<Chapter>
|
||||
Range of chapters in a book
|
||||
<Book>:<Chapter>:<Verse>-<Verse>
|
||||
|
|
|
|||
25
kjv.awk
25
kjv.awk
|
|
@ -24,6 +24,7 @@ function parseref(ref, arr) {
|
|||
# 1. <book>
|
||||
# 2. <book>:?<chapter>
|
||||
# 3. <book>:?<chapter>:<verse>
|
||||
# 3a. <book>:?<chapter>:<verse>[,<verse>]...
|
||||
# 4. <book>:?<chapter>-<chapter>
|
||||
# 5. <book>:?<chapter>:<verse>-<verse>
|
||||
# 6. <book>:?<chapter>:<verse>-<chapter>:<verse>
|
||||
|
|
@ -32,7 +33,7 @@ function parseref(ref, arr) {
|
|||
# 9. <book>:?<chapter>/search
|
||||
|
||||
if (match(ref, "^[1-9]?[a-zA-Z ]+")) {
|
||||
# 1, 2, 3, 4, 5, 6, 8, 9
|
||||
# 1, 2, 3, 3a, 4, 5, 6, 8, 9
|
||||
arr["book"] = substr(ref, 1, RLENGTH)
|
||||
ref = substr(ref, RLENGTH + 1)
|
||||
} else if (match(ref, "^/")) {
|
||||
|
|
@ -44,7 +45,7 @@ function parseref(ref, arr) {
|
|||
}
|
||||
|
||||
if (match(ref, "^:?[1-9]+[0-9]*")) {
|
||||
# 2, 3, 4, 5, 6, 9
|
||||
# 2, 3, 3a, 4, 5, 6, 9
|
||||
if (sub("^:", "", ref)) {
|
||||
arr["chapter"] = int(substr(ref, 1, RLENGTH - 1))
|
||||
ref = substr(ref, RLENGTH)
|
||||
|
|
@ -64,7 +65,7 @@ function parseref(ref, arr) {
|
|||
}
|
||||
|
||||
if (match(ref, "^:[1-9]+[0-9]*")) {
|
||||
# 3, 5, 6
|
||||
# 3, 3a, 5, 6
|
||||
arr["verse"] = int(substr(ref, 2, RLENGTH - 1))
|
||||
ref = substr(ref, RLENGTH + 1)
|
||||
} else if (match(ref, "^-[1-9]+[0-9]*$")) {
|
||||
|
|
@ -93,6 +94,20 @@ function parseref(ref, arr) {
|
|||
} else if (ref == "") {
|
||||
# 3
|
||||
return "exact"
|
||||
} else if (match(ref, "^,[1-9]+[0-9]*")) {
|
||||
# 3a
|
||||
arr["verse", arr["verse"]] = 1;
|
||||
delete arr["verse"];
|
||||
do {
|
||||
arr["verse", substr(ref, 2, RLENGTH - 1)] = 1;
|
||||
ref = substr(ref, RLENGTH + 1);
|
||||
} while (match(ref, "^,[1-9]+[0-9]*"));
|
||||
|
||||
if (ref != "") {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
return "exact_set"
|
||||
} else {
|
||||
return "unknown"
|
||||
}
|
||||
|
|
@ -165,6 +180,10 @@ cmd == "ref" && mode == "exact" && bookmatches($1, $2, p["book"]) && (p["chapter
|
|||
processline()
|
||||
}
|
||||
|
||||
cmd == "ref" && mode == "exact_set" && bookmatches($1, $2, p["book"]) && (p["chapter"] == "" || $4 == p["chapter"]) && p["verse", $5] {
|
||||
processline()
|
||||
}
|
||||
|
||||
cmd == "ref" && mode == "range" && bookmatches($1, $2, p["book"]) && ((p["chapter_end"] == "" && $4 == p["chapter"]) || ($4 >= p["chapter"] && $4 <= p["chapter_end"])) && (p["verse"] == "" || $5 >= p["verse"]) && (p["verse_end"] == "" || $5 <= p["verse_end"]) {
|
||||
processline()
|
||||
}
|
||||
|
|
|
|||
4
kjv.sh
4
kjv.sh
|
|
@ -29,8 +29,8 @@ show_help() {
|
|||
echo " Individual book"
|
||||
echo " <Book>:<Chapter>"
|
||||
echo " Individual chapter of a book"
|
||||
echo " <Book>:<Chapter>:<Verse>"
|
||||
echo " Individual verse of a specific chapter of a book"
|
||||
echo " <Book>:<Chapter>:<Verse>[,<Verse>]..."
|
||||
echo " Individual verse(s) of a specific chapter of a book"
|
||||
echo " <Book>:<Chapter>-<Chapter>"
|
||||
echo " Range of chapters in a book"
|
||||
echo " <Book>:<Chapter>:<Verse>-<Verse>"
|
||||
|
|
|
|||
Loading…
Reference in New Issue