From 63035ca028b4f7b1c619729b1eeb2a3189483b89 Mon Sep 17 00:00:00 2001 From: Jan Lukas Gernert Date: Sat, 25 Feb 2023 00:43:42 +0100 Subject: [PATCH] fmt --- src/full_text_parser/metadata.rs | 5 ++++- src/full_text_parser/mod.rs | 4 +--- src/full_text_parser/readability/mod.rs | 3 +-- src/full_text_parser/readability/tests.rs | 8 +++++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/full_text_parser/metadata.rs b/src/full_text_parser/metadata.rs index 47f89ae..c05a385 100644 --- a/src/full_text_parser/metadata.rs +++ b/src/full_text_parser/metadata.rs @@ -23,7 +23,10 @@ pub fn extract( let new_title = constants::TITLE_CUT_END.replace(&title, "$1"); let word_count = constants::WORD_COUNT.split(&title).count(); if word_count < 3 { - constants::TITLE_CUT_FRONT.replace(&title, "$1").trim().to_string() + constants::TITLE_CUT_FRONT + .replace(&title, "$1") + .trim() + .to_string() } else { new_title.trim().to_string() } diff --git a/src/full_text_parser/mod.rs b/src/full_text_parser/mod.rs index ac02695..7703182 100644 --- a/src/full_text_parser/mod.rs +++ b/src/full_text_parser/mod.rs @@ -837,9 +837,7 @@ impl FullTextParser { Ok(()) } - pub(crate) fn post_process_content( - root: &mut Node - ) -> Result<(), FullTextParserError> { + pub(crate) fn post_process_content(root: &mut Node) -> Result<(), FullTextParserError> { Self::clean_classes(root)?; Self::simplify_nested_elements(root)?; Ok(()) diff --git a/src/full_text_parser/readability/mod.rs b/src/full_text_parser/readability/mod.rs index 602fe73..3ea3ddc 100644 --- a/src/full_text_parser/readability/mod.rs +++ b/src/full_text_parser/readability/mod.rs @@ -280,8 +280,7 @@ impl Readability { constants::MINIMUM_TOPCANDIDATES, ); for ancestor in alternative_candidate_ancestors.iter().take(tmp) { - lists_containing_this_ancestor += - if ancestor == parent { 1 } else { 0 }; + lists_containing_this_ancestor += if ancestor == parent { 1 } else { 0 }; } if lists_containing_this_ancestor >= constants::MINIMUM_TOPCANDIDATES { diff --git a/src/full_text_parser/readability/tests.rs b/src/full_text_parser/readability/tests.rs index 06b57c8..f783951 100644 --- a/src/full_text_parser/readability/tests.rs +++ b/src/full_text_parser/readability/tests.rs @@ -43,11 +43,13 @@ async fn run_test(name: &str) { article.document = Some(article_document); let html = article.get_content().unwrap(); - let expected = std::fs::read_to_string(format!("./resources/tests/readability/{name}/expected.html")) - .expect("Failed to read expected HTML"); + let expected = std::fs::read_to_string(format!( + "./resources/tests/readability/{name}/expected.html" + )) + .expect("Failed to read expected HTML"); //std::fs::write("expected.html", &html).unwrap(); - + assert_eq!(expected, html); }