diff --git a/src/renderer/pandoc/mod.rs b/src/renderer/pandoc/mod.rs index 1a4362af..c428e2b0 100644 --- a/src/renderer/pandoc/mod.rs +++ b/src/renderer/pandoc/mod.rs @@ -3,34 +3,40 @@ use book::MDBook; use book::bookitem::BookItem; use std::error::Error; +use std::process::Command; -enum PandocOutput { - Epub, - Pdf -} - -pub struct Pandoc { - output: PandocOutput -} +pub struct Pandoc; impl Pandoc { pub fn new() -> Pandoc { - Pandoc { output: PandocOutput::Epub } + Pandoc } } impl Renderer for Pandoc { fn render(&self, book: &MDBook) -> Result<(), Box> { + let mut paths = vec!(); for item in book.iter() { match *item { - BookItem::Chapter(ref title, _) => { - println!("{}", title) + BookItem::Chapter(_, ref ch) => { + paths.push(book.get_src().join(&ch.path).into_os_string()); }, - _ => println!("Something I don't understand") + _ => println!("FIXME: don't understand this kind of BookItem") } } - Ok(()) + let output = Command::new("pandoc") + .arg("-S") + .arg("-osample.epub") + .args(&paths) + .output(); + + match output { + Ok(_) => Ok(()), + Err(e) => Err(Box::new(e)) + } + // FIXME: why doesn't this work + // output.map(|_| ()).map_err(|e| Box::new(e)) } } \ No newline at end of file