feat: add inline-toc flag

This commit is contained in:
Kenneth Gitere 2021-06-17 17:32:53 +03:00
parent c6c10689eb
commit 754365a42a
2 changed files with 15 additions and 2 deletions

View file

@ -21,6 +21,7 @@ pub struct AppConfig {
pub can_disable_progress_bar: bool, pub can_disable_progress_bar: bool,
pub start_time: DateTime<Local>, pub start_time: DateTime<Local>,
pub is_logging_to_file: bool, pub is_logging_to_file: bool,
pub inline_toc: bool,
} }
impl AppConfig { impl AppConfig {
@ -86,7 +87,14 @@ impl AppConfig {
Arg::with_name("log-to-file") Arg::with_name("log-to-file")
.long("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") .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()) Self::try_from(app.get_matches())
} }
@ -169,6 +177,7 @@ impl<'a> TryFrom<ArgMatches<'a>> for AppConfig {
4..=u64::MAX => LogLevel::Debug, 4..=u64::MAX => LogLevel::Debug,
}) })
.is_logging_to_file(arg_matches.is_present("log-to-file")) .is_logging_to_file(arg_matches.is_present("log-to-file"))
.inline_toc(arg_matches.is_present("inline-toc"))
.output_directory( .output_directory(
arg_matches arg_matches
.value_of("output_directory") .value_of("output_directory")

View file

@ -66,7 +66,11 @@ pub fn generate_epubs(
} }
}; };
debug!("Creating {:?}", name); debug!("Creating {:?}", name);
if app_config.inline_toc {
epub.inline_toc(); epub.inline_toc();
}
match epub.stylesheet(stylesheet.as_bytes()) { match epub.stylesheet(stylesheet.as_bytes()) {
Ok(_) => (), Ok(_) => (),
Err(e) => { Err(e) => {