Merge pull request #380 from ffissore/master

Fixed wrong filename when post processing html
This commit is contained in:
Mathieu David 2017-08-03 16:27:18 +02:00 committed by GitHub
commit 373e36ebfb
1 changed files with 5 additions and 6 deletions

View File

@ -69,9 +69,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());
@ -117,9 +116,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);
@ -274,7 +273,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"),