Dont import everything

This commit is contained in:
Jake Howard 2017-08-16 11:10:04 +01:00
parent 47f78b94cf
commit bb366950b9
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -1,6 +1,5 @@
use config::Config; use config::Config;
use pandoc::{Pandoc, OutputFormat, InputFormat, InputKind, OutputKind, PandocOutput, PandocError, use pandoc::{self, Pandoc, PandocOutput, PandocError};
PandocOption};
use std::env::{current_dir, current_exe}; use std::env::{current_dir, current_exe};
use std::path::PathBuf; use std::path::PathBuf;
use std::error::Error; use std::error::Error;
@ -15,16 +14,16 @@ fn add_path_hints(pandoc: &mut Pandoc, path: &mut PathBuf) {
fn execute_pandoc(config: Config, input: String) -> Result<PandocOutput, PandocError> { fn execute_pandoc(config: Config, input: String) -> Result<PandocOutput, PandocError> {
let mut pandoc = Pandoc::new(); let mut renderer = Pandoc::new();
pandoc.set_output_format(OutputFormat::Html5, vec![]); renderer.set_output_format(pandoc::OutputFormat::Html5, vec![]);
pandoc.set_input_format(InputFormat::Markdown, vec![]); renderer.set_input_format(pandoc::InputFormat::Markdown, vec![]);
pandoc.set_input(InputKind::Pipe(input)); renderer.set_input(pandoc::InputKind::Pipe(input));
pandoc.set_output(OutputKind::Pipe); renderer.set_output(pandoc::OutputKind::Pipe);
pandoc.add_option(PandocOption::Smart); renderer.add_option(pandoc::PandocOption::Smart);
pandoc.add_option(PandocOption::Standalone); renderer.add_option(pandoc::PandocOption::Standalone);
add_path_hints(&mut pandoc, &mut current_exe().unwrap()); add_path_hints(&mut renderer, &mut current_exe().unwrap());
add_path_hints(&mut pandoc, &mut current_dir().unwrap()); add_path_hints(&mut renderer, &mut current_dir().unwrap());
return pandoc.execute(); return renderer.execute();
} }
@ -34,7 +33,7 @@ pub fn render(config: Config, input: String) -> Result<String, String> {
return Err(output.err().unwrap().description().into()); return Err(output.err().unwrap().description().into());
} }
return match output.unwrap() { return match output.unwrap() {
PandocOutput::ToBuffer(out) => Ok(out), pandoc::PandocOutput::ToBuffer(out) => Ok(out),
_ => Err("Incorrect output type.".into()), _ => Err("Incorrect output type.".into()),
}; };
} }