-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1.0: first working version; using integrated bible-versions; multi…
…ple verse, and chapter support
- Loading branch information
0 parents
commit edcf5c3
Showing
8 changed files
with
459 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.