Dont add too many paths to PATH when searching for pandoc exe

This commit is contained in:
Jake Howard 2017-08-31 08:45:14 +01:00
parent a51cc3ffdd
commit e42e51695b
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -4,15 +4,6 @@ use std::env::{current_dir, current_exe};
use std::path::PathBuf;
use std::error::Error;
fn add_path_hints(pandoc: &mut Pandoc, path: &mut PathBuf) {
let mut out = true;
while out {
pandoc.add_pandoc_path_hint(path);
out = path.pop();
}
}
fn execute_pandoc(config: Config, input: String) -> Result<PandocOutput, PandocError> {
let mut renderer = Pandoc::new();
renderer.set_output_format(pandoc::OutputFormat::Html5, vec![]);
@ -21,8 +12,7 @@ fn execute_pandoc(config: Config, input: String) -> Result<PandocOutput, PandocE
renderer.set_output(pandoc::OutputKind::Pipe);
renderer.add_option(pandoc::PandocOption::Smart);
renderer.add_option(pandoc::PandocOption::Standalone);
add_path_hints(&mut renderer, &mut current_exe().unwrap());
add_path_hints(&mut renderer, &mut current_dir().unwrap());
renderer.add_pandoc_path_hint(current_exe().unwrap().parent().unwrap());
return renderer.execute();
}