diff --git a/src/book/mod.rs b/src/book/mod.rs index a8f07575..1d261c9f 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -158,8 +158,9 @@ impl MDBook { fn execute_build_process(&self, renderer: &Renderer) -> Result<()> { let mut preprocessed_book = self.book.clone(); - let preprocess_ctx = - PreprocessorContext::new(self.root.clone(), self.config.clone()); + let preprocess_ctx = PreprocessorContext::new(self.root.clone(), + self.config.clone(), + renderer.name().to_string()); for preprocessor in &self.preprocessors { debug!("Running the {} preprocessor.", preprocessor.name()); @@ -227,7 +228,10 @@ impl MDBook { let temp_dir = TempFileBuilder::new().prefix("mdbook-").tempdir()?; - let preprocess_context = PreprocessorContext::new(self.root.clone(), self.config.clone()); + // FIXME: Is "test" the proper renderer name to use here? + let preprocess_context = PreprocessorContext::new(self.root.clone(), + self.config.clone(), + "test".to_string()); let book = LinkPreprocessor::new().run(&preprocess_context, self.book.clone())?; // Index Preprocessor is disabled so that chapter paths continue to point to the diff --git a/src/preprocess/mod.rs b/src/preprocess/mod.rs index 555768b3..7c78e058 100644 --- a/src/preprocess/mod.rs +++ b/src/preprocess/mod.rs @@ -19,12 +19,14 @@ pub struct PreprocessorContext { pub root: PathBuf, /// The book configuration (`book.toml`). pub config: Config, + /// The `Renderer` this preprocessor is being used with. + pub renderer: String, } impl PreprocessorContext { /// Create a new `PreprocessorContext`. - pub(crate) fn new(root: PathBuf, config: Config) -> Self { - PreprocessorContext { root, config } + pub(crate) fn new(root: PathBuf, config: Config, renderer: String) -> Self { + PreprocessorContext { root, config, renderer } } }