Fixed wrong filename when post processing html

This commit is contained in:
Federico Fissore 2017-07-24 11:22:14 +02:00
parent 55e7e82e5c
commit 07b80723b6
1 changed files with 5 additions and 6 deletions

View File

@ -68,9 +68,8 @@ impl HtmlHandlebars {
// Render the handlebars template with the data // Render the handlebars template with the data
debug!("[*]: Render template"); debug!("[*]: Render template");
let rendered = ctx.handlebars.render("index", &ctx.data)?; let rendered = ctx.handlebars.render("index", &ctx.data)?;
let rendered = self.post_process(rendered);
let filename = Path::new(&ch.path).with_extension("html"); 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 // Write to file
info!("[*] Creating {:?} ✓", filename.display()); info!("[*] Creating {:?} ✓", filename.display());
@ -116,9 +115,9 @@ impl HtmlHandlebars {
Ok(()) Ok(())
} }
fn post_process(&self, rendered: String) -> String { fn post_process(&self, rendered: String, filename: &str) -> String {
let rendered = build_header_links(&rendered, "print.html"); let rendered = build_header_links(&rendered, filename);
let rendered = fix_anchor_links(&rendered, "print.html"); let rendered = fix_anchor_links(&rendered, filename);
let rendered = fix_code_blocks(&rendered); let rendered = fix_code_blocks(&rendered);
let rendered = add_playpen_pre(&rendered); let rendered = add_playpen_pre(&rendered);
@ -273,7 +272,7 @@ impl Renderer for HtmlHandlebars {
debug!("[*]: Render template"); debug!("[*]: Render template");
let rendered = handlebars.render("index", &data)?; let rendered = handlebars.render("index", &data)?;
let rendered = self.post_process(rendered); let rendered = self.post_process(rendered, "print.html");
book.write_file( book.write_file(
Path::new("print").with_extension("html"), Path::new("print").with_extension("html"),