From 754365a42aa56673cda9d1ba7abe9be2c4151b0b Mon Sep 17 00:00:00 2001 From: Kenneth Gitere Date: Thu, 17 Jun 2021 17:32:53 +0300 Subject: [PATCH] feat: add `inline-toc` flag --- src/cli.rs | 11 ++++++++++- src/epub.rs | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 763898f..3ffd4f7 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -21,6 +21,7 @@ pub struct AppConfig { pub can_disable_progress_bar: bool, pub start_time: DateTime, pub is_logging_to_file: bool, + pub inline_toc: bool, } impl AppConfig { @@ -86,7 +87,14 @@ impl AppConfig { Arg::with_name("log-to-file") .long("log-to-file") .help("Enables logging of events to a file located in .paperoni/logs with a default log level of debug. Use -v to specify the logging level") - .takes_value(false)); + .takes_value(false)) + .arg( + Arg::with_name("inline-toc") + .long("inline-toc") + .requires("output_name") + .help("Add an inlined Table of Contents page at the start of the merged article.") + .long_help("Add an inlined Table of Contents page at the start of the merged article. This does not affect the Table of Contents navigation") + ); Self::try_from(app.get_matches()) } @@ -169,6 +177,7 @@ impl<'a> TryFrom> for AppConfig { 4..=u64::MAX => LogLevel::Debug, }) .is_logging_to_file(arg_matches.is_present("log-to-file")) + .inline_toc(arg_matches.is_present("inline-toc")) .output_directory( arg_matches .value_of("output_directory") diff --git a/src/epub.rs b/src/epub.rs index e54801e..f3e37f4 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -66,7 +66,11 @@ pub fn generate_epubs( } }; debug!("Creating {:?}", name); - epub.inline_toc(); + + if app_config.inline_toc { + epub.inline_toc(); + } + match epub.stylesheet(stylesheet.as_bytes()) { Ok(_) => (), Err(e) => {