From 9e59cd7e6a21751420ccbb853ac883154c6e578e Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 29 Sep 2016 13:10:20 +0200 Subject: dynamischere sektionssuche, jetzt auch mit thumb images. koennten wir eigentlich in irgendeine config-datei auslagern. diff --git a/src/main.rs b/src/main.rs index b733e6f..2123c6b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,15 +13,11 @@ mod pre_process; use pre_process::Section; fn main() { - let raw_files = env::var("RAW_FILES").unwrap_or("S:\\grilist\\acd\\acd_character_parser\\characters\\".into()); + let raw_files = env::var("RAW_FILES").unwrap_or("characters".into()); let base_path = Path::new(&raw_files); let mut sections: Vec
= vec![]; - sections.push(Section { - name: "image".into(), - re: Regex::new(r#"(?is)

.*

View Full Size Image"#).unwrap(), - content: String::new(), - }); + sections.push(Section::new("image", r#"(?is)

.*.*?

View Full Size Image"#, vec!["thumb".into(), "full".into()])); for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) { let mut f = File::open(entry.path()).expect("could not open file"); @@ -35,6 +31,6 @@ fn main() { pre_process::split_sections(&buf, &mut sections); - println!("{}", sections[0].content); + println!("{:?}", sections[0].data); } } diff --git a/src/pre_process.rs b/src/pre_process.rs index d69cfce..0d8c6be 100644 --- a/src/pre_process.rs +++ b/src/pre_process.rs @@ -1,5 +1,7 @@ use super::regex::Regex; +use std::collections::HashMap; + pub fn strip_irrelevant_content(s: &str) -> String { let mut retn = ""; match s.find(r#"