diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..606e292 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +wrap_comments = true \ No newline at end of file diff --git a/src/engines/answer/calc.rs b/src/engines/answer/calc.rs index c7f82c4..f72dc39 100644 --- a/src/engines/answer/calc.rs +++ b/src/engines/answer/calc.rs @@ -78,7 +78,8 @@ fn evaluate(query: &str, html: bool) -> Option { } } - // if the result was a single hex number then we add the decimal equivalent below + // if the result was a single hex number then we add the decimal equivalent + // below if spans.len() == 1 && spans[0].kind == fend_core::SpanKind::Number && spans[0].text.starts_with("0x") @@ -145,27 +146,6 @@ fn evaluate_into_spans(query: &str, multiline: bool) -> Vec { } } } - // // match queries like "ord(≿)" or just "≿" - // let re = regex!( - // r"^(?:(?:chr|charcode|char|charcode)(?:| for| of)\s*\(?\s*(\d+)\s*\)?)|(?:(\d+) (?:|to |into |as )(?:charcode|char|character))$" - // ); - // if let Some(m) = re.captures(query) { - // if let Some(ord) = m - // .get(1) - // .or_else(|| m.get(2)) - // .and_then(|m| m.as_str().parse::().ok()) - // { - // let chr = std::char::from_u32(ord); - // if let Some(chr) = chr { - // return vec![Span { - // text: format!("'{chr}'"), - // kind: fend_core::SpanKind::String, - // }]; - // } else { - // return vec![]; - // } - // } - // } // fend incorrectly triggers on these often { @@ -174,12 +154,14 @@ fn evaluate_into_spans(query: &str, multiline: bool) -> Vec { return vec![]; } - // probably a query operator thing or a url, fend evaluates these but it shouldn't + // probably a query operator thing or a url, fend evaluates these but it + // shouldn't if regex!("^[a-z]{2,}:").is_match(query) { return vec![]; } - // if it starts and ends with quotes then the person was just searching in quotes and didn't mean to evaluate a string + // if it starts and ends with quotes then the person was just searching in + // quotes and didn't mean to evaluate a string if query.starts_with('"') && query.ends_with('"') && query.chars().filter(|c| *c == '"').count() == 2 diff --git a/src/engines/answer/dictionary.rs b/src/engines/answer/dictionary.rs index 79f3f42..304232b 100644 --- a/src/engines/answer/dictionary.rs +++ b/src/engines/answer/dictionary.rs @@ -128,8 +128,9 @@ pub fn parse_response(HttpResponse { res, body }: &HttpResponse) -> eyre::Result fn key_to_title(key: &str) -> String { // https://github.com/wikimedia/mediawiki-title - // In general, the page title is converted to the mediawiki DB key format by trimming spaces, - // replacing whitespace symbols to underscores and applying wiki-specific capitalization rules. + // In general, the page title is converted to the mediawiki DB key format by + // trimming spaces, replacing whitespace symbols to underscores and applying + // wiki-specific capitalization rules. let title = key.trim().replace('_', " "); let mut c = title.chars(); diff --git a/src/engines/mod.rs b/src/engines/mod.rs index f8c776c..20efe14 100644 --- a/src/engines/mod.rs +++ b/src/engines/mod.rs @@ -546,7 +546,8 @@ fn merge_engine_responses(responses: HashMap) -> Respons for (engine, response) in responses { for (result_index, search_result) in response.search_results.into_iter().enumerate() { - // position 1 has a score of 1, position 2 has a score of 0.5, position 3 has a score of 0.33, etc. + // position 1 has a score of 1, position 2 has a score of 0.5, position 3 has a + // score of 0.33, etc. let base_result_score = 1. / (result_index + 1) as f64; let result_score = base_result_score * engine.weight(); @@ -554,7 +555,8 @@ fn merge_engine_responses(responses: HashMap) -> Respons .iter_mut() .find(|r| r.url == search_result.url) { - // if the weight of this engine is higher than every other one then replace the title and description + // if the weight of this engine is higher than every other one then replace the + // title and description if engine.weight() > existing_result .engines @@ -639,7 +641,8 @@ fn merge_autocomplete_responses(responses: HashMap>) -> Vec< for (engine, response) in responses { for (result_index, autocomplete_result) in response.into_iter().enumerate() { - // position 1 has a score of 1, position 2 has a score of 0.5, position 3 has a score of 0.33, etc. + // position 1 has a score of 1, position 2 has a score of 0.5, position 3 has a + // score of 0.33, etc. let base_result_score = 1. / (result_index + 1) as f64; let result_score = base_result_score * engine.weight(); diff --git a/src/engines/search/google.rs b/src/engines/search/google.rs index 146171b..11d670f 100644 --- a/src/engines/search/google.rs +++ b/src/engines/search/google.rs @@ -22,7 +22,8 @@ pub fn parse_response(body: &str) -> eyre::Result { body, ParseOpts::new() // xpd is weird, some results have it but it's usually used for ads? - // the :first-child filters out the ads though since for ads the first child is always a span + // the :first-child filters out the ads though since for ads the first child is always a + // span .result("div.g > div, div.xpd > div:first-child") .title("h3") .href("a[href]")