Skip to content

Commit

Permalink
v0.1.0: first working version; using integrated bible-versions; multi…
Browse files Browse the repository at this point in the history
…ple verse, and chapter support
  • Loading branch information
thebiblelover7 committed Jan 3, 2024
0 parents commit edcf5c3
Show file tree
Hide file tree
Showing 8 changed files with 459 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
315 changes: 315 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "bible-spotlight"
version = "0.1.0"
authors = ["Adriel <[email protected]>"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
colored = "2.1.0"
regex = "1.10.2"
roxmltree = "0.19.0"
rusqlite = "0.30.0"
Binary file added bible-versions/KJV+.SQLite3
Binary file not shown.
Binary file added bible-versions/NIVUK.SQLite3
Binary file not shown.
23 changes: 23 additions & 0 deletions src/interpreter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use regex::Regex;

use crate::BibleReference;


pub fn parse(bible_ref: String) -> Option<BibleReference> {

let rgx = Regex::new(r"(?P<book>\D+)(?P<chapter>\d+)(-(?P<end_chapter>\d+))?(:((?P<verse>\d+)(-(?P<end_verse>\d+))?))?").unwrap();
if let Some(caps) = rgx.captures(&bible_ref) {
let book = caps.name("book")?.as_str().to_string();
let chapter = caps.name("chapter")?.as_str().parse().ok()?;
let end_chapter = caps.name("end_chapter").map(|m| m.as_str().parse().ok()).flatten().unwrap_or(chapter);
let verse = match caps.name("verse") {
Some (m) => (m.as_str().parse::<u32>().ok()?..=caps.name("end_verse").map(|m| m.as_str().parse::<u32>().ok()).flatten().unwrap_or(m.as_str().parse().ok()?)).collect(),
None => Vec::new(),
};
return Some(BibleReference { book, chapter: (chapter..=end_chapter).collect(), verse });
} else {
return None;
}


}
Loading

0 comments on commit edcf5c3

Please sign in to comment.