From d50bbdfb580ff97487d2e0fbd3d5f2e8b29a0b71 Mon Sep 17 00:00:00 2001 From: Kenneth Gitere Date: Wed, 9 Jun 2021 07:26:52 +0300 Subject: [PATCH] fix: minor fixes - restore default debug level when logging to file - return early from generating epubs if there are no articles - fix serialization bug in creating attributes --- src/cli.rs | 8 +++++++- src/epub.rs | 4 ++++ src/extractor.rs | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index eb6c610..22cc156 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -155,7 +155,13 @@ impl<'a> TryFrom> for AppConfig { arg_matches.is_present("verbosity") && !arg_matches.is_present("log-to-file"), ) .log_level(match arg_matches.occurrences_of("verbosity") { - 0 => LogLevel::Off, + 0 => { + if !arg_matches.is_present("log-to-file") { + LogLevel::Off + } else { + LogLevel::Debug + } + } 1 => LogLevel::Error, 2 => LogLevel::Warn, 3 => LogLevel::Info, diff --git a/src/epub.rs b/src/epub.rs index 667e2f7..e573260 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -18,6 +18,10 @@ pub fn generate_epubs( app_config: &AppConfig, successful_articles_table: &mut Table, ) -> Result<(), Vec> { + if articles.is_empty() { + return Ok(()); + } + let bar = if app_config.can_disable_progress_bar { ProgressBar::hidden() } else { diff --git a/src/extractor.rs b/src/extractor.rs index 2cf3f25..110357b 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -103,7 +103,7 @@ pub fn serialize_to_xhtml( let attrs_str = attrs .map .iter() - .filter(|(k, _)| &k.local != "\"") + .filter(|(k, _)| !k.local.contains("\"")) .map(|(k, v)| { format!( "{}=\"{}\"",