First experiment with building a new renderer.
This commit is contained in:
parent
e286b208da
commit
8476a3d03d
|
@ -8,7 +8,7 @@ use std::process::Command;
|
||||||
|
|
||||||
use {BookConfig, BookItem, theme, parse, utils};
|
use {BookConfig, BookItem, theme, parse, utils};
|
||||||
use book::BookItems;
|
use book::BookItems;
|
||||||
use renderer::{Renderer, HtmlHandlebars};
|
use renderer::{Renderer, HtmlHandlebars, Pandoc};
|
||||||
|
|
||||||
|
|
||||||
pub struct MDBook {
|
pub struct MDBook {
|
||||||
|
@ -38,7 +38,7 @@ impl MDBook {
|
||||||
.set_src(&root.join("src"))
|
.set_src(&root.join("src"))
|
||||||
.set_dest(&root.join("book"))
|
.set_dest(&root.join("book"))
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
renderer: Box::new(HtmlHandlebars::new()),
|
renderer: Box::new(Pandoc::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
pub use self::renderer::Renderer;
|
pub use self::renderer::Renderer;
|
||||||
pub use self::html_handlebars::HtmlHandlebars;
|
pub use self::html_handlebars::HtmlHandlebars;
|
||||||
|
pub use self::pandoc::Pandoc;
|
||||||
|
|
||||||
pub mod renderer;
|
pub mod renderer;
|
||||||
|
mod pandoc;
|
||||||
mod html_handlebars;
|
mod html_handlebars;
|
|
@ -0,0 +1,36 @@
|
||||||
|
use renderer::Renderer;
|
||||||
|
use book::MDBook;
|
||||||
|
use book::bookitem::BookItem;
|
||||||
|
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
|
enum PandocOutput {
|
||||||
|
Epub,
|
||||||
|
Pdf
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Pandoc {
|
||||||
|
output: PandocOutput
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pandoc {
|
||||||
|
pub fn new() -> Pandoc {
|
||||||
|
Pandoc { output: PandocOutput::Epub }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Renderer for Pandoc {
|
||||||
|
fn render(&self, book: &MDBook) -> Result<(), Box<Error>> {
|
||||||
|
|
||||||
|
for item in book.iter() {
|
||||||
|
match *item {
|
||||||
|
BookItem::Chapter(ref title, _) => {
|
||||||
|
println!("{}", title)
|
||||||
|
},
|
||||||
|
_ => println!("Something I don't understand")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue