From 47f78b94cfcb599b1314aba7e28748a57b83504d Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 16 Aug 2017 00:21:53 +0100 Subject: [PATCH] Traverse up tree for path hints --- src/build/pandoc.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/build/pandoc.rs b/src/build/pandoc.rs index 9275402..2b7a5f0 100644 --- a/src/build/pandoc.rs +++ b/src/build/pandoc.rs @@ -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 { 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(); }