From cd18b7aaac138cdd21c35b0cd9d64c6ac626c30f Mon Sep 17 00:00:00 2001 From: command_block Date: Sat, 11 Nov 2023 21:48:57 +0800 Subject: [PATCH] Fix no-section-label --- src/generator.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/generator.rs b/src/generator.rs index dcf9d4f5f..4bdce59d1 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -161,7 +161,15 @@ impl<'a> Generator<'a> { content_path ); let path = content_path.with_extension("html").display().to_string(); - let mut content = EpubContent::new(path, rendered.as_bytes()).title(format!("{ch}")); + let title = if self.config.no_section_label { + ch.name.clone() + } else if let Some(ref section_number) = ch.number { + format!{"{} {}", section_number, ch.name} + } else { + ch.name.clone() + }; + + let mut content = EpubContent::new(path, rendered.as_bytes()).title(title); let level = ch.number.as_ref().map(|n| n.len() as i32 - 1).unwrap_or(0); content = content.level(level);