diff --git a/src/book/chapter.rs b/src/book/chapter.rs index c048020c..90086dfa 100644 --- a/src/book/chapter.rs +++ b/src/book/chapter.rs @@ -220,9 +220,7 @@ impl Chapter { debug!("[*]: Reading file"); try!(f.read_to_string(&mut content)); - // Render markdown using the pulldown-cmark crate content = utils::strip_toml_header(&content); - content = utils::render_markdown(&content); Ok(content) } diff --git a/src/book/mod.rs b/src/book/mod.rs index ae604ab0..89b7a6c4 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -50,8 +50,8 @@ pub struct MDBook { render_intent: RenderIntent, /// The book, or books in case of translations, accessible with a String - /// key. The keys can be two-letter codes of the translation such as 'en' or - /// 'fr', but this is not enforced. + /// key. The keys are expected to be the same as the two-letter codes of the + /// language, such as 'en' or 'fr'. /// /// The String keys will be sub-folders where the translation's Markdown /// sources are expected. diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index a32e3207..6eb27d73 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -125,6 +125,10 @@ impl Renderer for HtmlHandlebars { &book_project.get_dest_base())); } + // Concatenate the content (as rendered from Markdown) of each chapter + // for writing print.html in the end + let mut print_content: String = String::new(); + debug!("[fn]: render"); let mut handlebars = Handlebars::new(); @@ -204,7 +208,7 @@ impl Renderer for HtmlHandlebars { content = helpers::playpen::render_playpen(&content, p); } - let mut data = try!(make_data(&book, &chapter, &content, &book_project.livereload_script)); + let mut data = try!(make_data(&book, &chapter, &book_project.livereload_script)); data.remove("path_to_root"); data.insert("path_to_root".to_owned(), "".to_json()); @@ -279,14 +283,7 @@ impl HtmlHandlebars { handlebars: &Handlebars) -> Result<(), Box> { - let mut content = try!(chapter.read_content_using(&book.config.src)); - - // Parse for playpen links - if let Some(p) = book.config.get_src().join(&chapter.path).parent() { - content = helpers::playpen::render_playpen(&content, p); - } - - let data = try!(make_data(book, chapter, &content, livereload_script)); + let data = try!(make_data(book, chapter, livereload_script)); // Rendere the handlebars template with the data debug!("[*]: Render template"); @@ -313,7 +310,6 @@ impl HtmlHandlebars { fn make_data(book: &Book, chapter: &Chapter, - content: &str, livereload_script: &Option) -> Result, Box> { @@ -356,6 +352,14 @@ fn make_data(book: &Book, }, } + let mut content = try!(chapter.read_content_using(&book.config.src)); + content = utils::render_markdown(&content); + + // Parse for playpen links + if let Some(p) = book.config.get_src().join(&chapter.path).parent() { + content = helpers::playpen::render_playpen(&content, p); + } + data.insert("content".to_owned(), content.to_json()); data.insert("path_to_root".to_owned(), utils::fs::path_to_root(&path).to_json());