Traverse up tree for path hints
This commit is contained in:
parent
c36f3987d1
commit
47f78b94cf
1 changed files with 11 additions and 2 deletions
|
@ -5,16 +5,25 @@ 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.join("lib"));
|
||||
out = path.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn execute_pandoc(config: Config, input: String) -> Result<PandocOutput, PandocError> {
|
||||
let mut pandoc = Pandoc::new();
|
||||
pandoc.add_pandoc_path_hint(¤t_dir().unwrap().join("lib"));
|
||||
pandoc.add_pandoc_path_hint(¤t_exe().unwrap().parent().unwrap().join("lib"));
|
||||
pandoc.set_output_format(OutputFormat::Html5, vec![]);
|
||||
pandoc.set_input_format(InputFormat::Markdown, vec![]);
|
||||
pandoc.set_input(InputKind::Pipe(input));
|
||||
pandoc.set_output(OutputKind::Pipe);
|
||||
pandoc.add_option(PandocOption::Smart);
|
||||
pandoc.add_option(PandocOption::Standalone);
|
||||
add_path_hints(&mut pandoc, &mut current_exe().unwrap());
|
||||
add_path_hints(&mut pandoc, &mut current_dir().unwrap());
|
||||
return pandoc.execute();
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue