artifacts.rs
1 use crate::sourcing::sources::Source; 2 3 pub fn line_is_an_artifact(line: &str, source: &Source) -> bool { 4 let mut truth_values: Vec<bool> = Vec::new(); 5 for group in [ 6 &source.footnote_indicators, 7 &source.header_indicators, 8 &source.named_artifacts, 9 ] { 10 if !truth_values.contains(&true) { 11 if let Some(values) = group { 12 let truth_value = values.iter().any(|item| line.contains(item)); 13 truth_values.push(truth_value) 14 } 15 } else { 16 return true; 17 } 18 } 19 20 // You only reach this point if the line isn't an artifact of some other type 21 if let Some(regexes) = &source.regexes { 22 regexes.iter().any(|regex| regex.is_match(line)) 23 } else { 24 false 25 } 26 }