Skip to content

Commit

Permalink
Merge pull request Michael-F-Bryan#85 from Zh40Le1ZOOB/master
Browse files Browse the repository at this point in the history
Fix no-section-label
  • Loading branch information
blandger authored Nov 11, 2023
2 parents 3b1d377 + cd18b7a commit db145fc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit db145fc

Please sign in to comment.