From 07b80723b697d2149f3ffcd872ae32b25b9c588c Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 24 Jul 2017 11:22:14 +0200 Subject: [PATCH] Fixed wrong filename when post processing html --- src/renderer/html_handlebars/hbs_renderer.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index b1ba47ca..05d6de93 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -68,9 +68,8 @@ impl HtmlHandlebars { // Render the handlebars template with the data debug!("[*]: Render template"); let rendered = ctx.handlebars.render("index", &ctx.data)?; - let rendered = self.post_process(rendered); - let filename = Path::new(&ch.path).with_extension("html"); + let rendered = self.post_process(rendered, filename.file_name().unwrap().to_str().unwrap_or("")); // Write to file info!("[*] Creating {:?} ✓", filename.display()); @@ -116,9 +115,9 @@ impl HtmlHandlebars { Ok(()) } - fn post_process(&self, rendered: String) -> String { - let rendered = build_header_links(&rendered, "print.html"); - let rendered = fix_anchor_links(&rendered, "print.html"); + fn post_process(&self, rendered: String, filename: &str) -> String { + let rendered = build_header_links(&rendered, filename); + let rendered = fix_anchor_links(&rendered, filename); let rendered = fix_code_blocks(&rendered); let rendered = add_playpen_pre(&rendered); @@ -273,7 +272,7 @@ impl Renderer for HtmlHandlebars { debug!("[*]: Render template"); let rendered = handlebars.render("index", &data)?; - let rendered = self.post_process(rendered); + let rendered = self.post_process(rendered, "print.html"); book.write_file( Path::new("print").with_extension("html"),