add regex support
This commit is contained in:
parent
11eb29df4f
commit
6d24b304ce
39
Cargo.lock
generated
39
Cargo.lock
generated
@ -48,6 +48,15 @@ dependencies = [
|
||||
"zerocopy 0.7.35",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
@ -288,6 +297,7 @@ dependencies = [
|
||||
"iced",
|
||||
"inline_colorization",
|
||||
"quick-xml",
|
||||
"regex",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@ -2546,6 +2556,35 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "renderdoc-sys"
|
||||
version = "1.1.0"
|
||||
|
@ -7,4 +7,5 @@ edition = "2024"
|
||||
iced = "0.13.1"
|
||||
inline_colorization = "0.1.6"
|
||||
quick-xml = { version="0.37.2", features=["serialize"] }
|
||||
regex = "1.11.1"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
|
11
README.md
11
README.md
@ -2,12 +2,13 @@
|
||||
|
||||
## Important Links
|
||||
|
||||
[Tanach.us](https://tanach.us)
|
||||
|
||||
[XML bible in 190+ languages](https://github.com/Beblia/Holy-Bible-XML-Format)
|
||||
[XML Bibles in 190+ languages](https://github.com/Beblia/Holy-Bible-XML-Format)
|
||||
|
||||
[HewbrewLexicon](https://github.com/openscriptures/HebrewLexicon/tree/master)
|
||||
|
||||
[27, 91, 49, 109, 91, 69, 110, 103, 108, 105, 115, 104, 32, 78, 65, 83, 66, 93, 32, 27, 91, 52, 109, 71, 101, 110, 101, 115, 105, 115, 32, 49, 58, 49, 27, 91, 48, 109, 58, 32, 73, 110, 32, 116, 104, 101, 32, 98, 101, 103, 105, 110, 110, 105, 110, 103, 32, 71, 111, 100, 32, 99, 114, 101, 97, 116, 101, 100, 32, 116, 104, 101, 32, 104, 101, 97, 118, 101, 110, 115, 32, 97, 110, 100, 32, 116, 104, 101, 32, 101, 97, 114, 116, 104, 46, 10]
|
||||
## Could be useful later links
|
||||
|
||||
[Tanach.us](https://tanach.us)
|
||||
|
||||
[AndBible's formats](https://github.com/AndBible/and-bible/wiki/Supported-3rd-party-module-formats)
|
||||
|
||||
[??, [, 1, m, [, E, n,,,]
|
@ -1,4 +1,5 @@
|
||||
use inline_colorization::*;
|
||||
use regex::Regex;
|
||||
use std::fmt::Display;
|
||||
|
||||
use serde::Deserialize;
|
||||
@ -74,11 +75,24 @@ pub const BOOKS_IN_ORDER: [&str; 66] = [
|
||||
|
||||
pub fn search_for_word(word: &str, from_files: &Bible) -> Vec<String> {
|
||||
let mut found = Vec::new();
|
||||
let regex = match Regex::new(&word.to_lowercase()) {
|
||||
Ok(re) => re,
|
||||
Err(err) => {
|
||||
eprintln!("{}", err);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
todo!("IDK what to do yet if building regex engine fails");
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
return Vec::new()
|
||||
},
|
||||
};
|
||||
|
||||
for test in &from_files.testaments {
|
||||
for book in &test.books {
|
||||
for chapter in &book.chapters {
|
||||
for verse in &chapter.verses {
|
||||
if verse.text.to_lowercase().contains(&word.to_lowercase()) {
|
||||
if regex.is_match(&verse.text.to_lowercase()) {
|
||||
found.push(format!("{} {}:{}", BOOKS_IN_ORDER[book.number-1], chapter.number, verse.number));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user