diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs
index 95acbd77..bf349ece 100644
--- a/src/renderer/html_handlebars/hbs_renderer.rs
+++ b/src/renderer/html_handlebars/hbs_renderer.rs
@@ -1,7 +1,7 @@
use renderer::html_handlebars::helpers;
use renderer::Renderer;
use book::MDBook;
-use book::bookitem::BookItem;
+use book::bookitem::{BookItem, Chapter};
use utils;
use theme::{self, Theme};
use regex::{Regex, Captures};
@@ -28,7 +28,7 @@ impl HtmlHandlebars {
}
fn render_item(&self, item: &BookItem, book: &MDBook, data: &mut serde_json::Map,
- print_content: &mut String, handlebars: &mut Handlebars, index: &mut bool, destination: &Path)
+ print_content: &mut String, handlebars: &mut Handlebars, is_index: bool, destination: &Path)
-> Result<(), Box> {
// FIXME: This should be made DRY-er and rely less on mutable state
match *item {
@@ -75,31 +75,8 @@ impl HtmlHandlebars {
book.write_file(filename, &rendered.into_bytes())?;
// Create an index.html from the first element in SUMMARY.md
- if *index {
- debug!("[*]: index.html");
-
- let mut content = String::new();
-
- let _source = File::open(destination.join(&ch.path.with_extension("html")))
- ?
- .read_to_string(&mut content);
-
- // This could cause a problem when someone displays
- // code containing
- // on the front page, however this case should be very very rare...
- content = content.lines()
- .filter(|line| !line.contains(" Result<(), Box> {
+ debug!("[*]: index.html");
+
+ let mut content = String::new();
+
+ let _source = File::open(destination.join(&ch.path.with_extension("html")))
+ ?
+ .read_to_string(&mut content);
+
+ // This could cause a problem when someone displays
+ // code containing
+ // on the front page, however this case should be very very rare...
+ content = content.lines()
+ .filter(|line| !line.contains(" String {
let rendered = build_header_links(rendered, "print.html");
let rendered = fix_anchor_links(rendered, "print.html");
@@ -216,9 +221,9 @@ impl Renderer for HtmlHandlebars {
"Unexpected error when constructing destination path")));
}
- let mut index = true;
- for item in book.iter() {
- self.render_item(item, book, &mut data, &mut print_content, &mut handlebars, &mut index, &destination)?;
+ for (i, item) in book.iter().enumerate() {
+ let is_index = i == 0;
+ self.render_item(item, book, &mut data, &mut print_content, &mut handlebars, is_index, &destination)?;
}
// Print version