diff --git a/module.wasm b/module.wasm index 185a950..68409ec 100644 Binary files a/module.wasm and b/module.wasm differ diff --git a/src/lib.rs b/src/lib.rs index 6f9ed7b..2b1a019 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,12 +49,11 @@ pub fn invoke(_ctx: Context, inputs: Inputs) -> Result { .require_json("norm") .map_err(|e| ModuleError::invalid_input(format!("norm shape: {e}")))?; - let re_para = Regex::new(r"§\s*(\d+[a-z]?)\s+([A-Z][A-Za-z0-9]+)") - .map_err(internal_re)?; - let re_art = Regex::new(r"Art(?:ikel|\.)\s*(\d+[a-z]?)\s+([A-Z][A-Za-z0-9]+)") - .map_err(internal_re)?; - let re_ivm = Regex::new(r"i\.\s?V\.\s?m\.\s+(?:§|Art\.?)\s*(\d+[a-z]?)") - .map_err(internal_re)?; + let re_para = Regex::new(r"§\s*(\d+[a-z]?)\s+([A-Z][A-Za-z0-9]+)").map_err(internal_re)?; + let re_art = + Regex::new(r"Art(?:ikel|\.)\s*(\d+[a-z]?)\s+([A-Z][A-Za-z0-9]+)").map_err(internal_re)?; + let re_ivm = + Regex::new(r"i\.\s?V\.\s?m\.\s+(?:§|Art\.?)\s*(\d+[a-z]?)").map_err(internal_re)?; let from_eli = norm.eli.unwrap_or_else(|| "eli/?".into()); let mut citations = Vec::new(); @@ -93,7 +92,10 @@ pub fn invoke(_ctx: Context, inputs: Inputs) -> Result { } } - let out = Output { from: from_eli, citations }; + let out = Output { + from: from_eli, + citations, + }; Outputs::new().with_json("citations", &out) } @@ -103,6 +105,7 @@ fn internal_re(e: E) -> ModuleError { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] use super::*; use regex::Regex; @@ -114,20 +117,31 @@ mod tests { for p in &norm.paragraphs { for c in re_para.captures_iter(&p.text) { cs.push(Citation { - to: format!("eli/bund/{}/{}", c[2].to_ascii_lowercase(), c[1].to_ascii_lowercase()), + to: format!( + "eli/bund/{}/{}", + c[2].to_ascii_lowercase(), + c[1].to_ascii_lowercase() + ), kind: "cites", raw: c[0].to_string(), }); } for c in re_art.captures_iter(&p.text) { cs.push(Citation { - to: format!("eli/eu/{}/art{}", c[2].to_ascii_lowercase(), c[1].to_ascii_lowercase()), + to: format!( + "eli/eu/{}/art{}", + c[2].to_ascii_lowercase(), + c[1].to_ascii_lowercase() + ), kind: "cites", raw: c[0].to_string(), }); } } - Output { from: norm.eli.unwrap_or_default(), citations: cs } + Output { + from: norm.eli.unwrap_or_default(), + citations: cs, + } } #[test]