diff --git a/examples/nop-preprocessor.rs b/examples/nop-preprocessor.rs index df8bd757..7c04417a 100644 --- a/examples/nop-preprocessor.rs +++ b/examples/nop-preprocessor.rs @@ -1,9 +1,10 @@ extern crate mdbook; +extern crate serde_json; #[macro_use] extern crate clap; use clap::{App, Arg, ArgMatches, SubCommand}; -use mdbook::preprocess::{Preprocessor, PreprocessorContext, CmdPreprocessor}; +use mdbook::preprocess::CmdPreprocessor; use std::process; use std::io; @@ -21,6 +22,8 @@ fn handle_preprocessing(args: &ArgMatches) { let (ctx, book) = CmdPreprocessor::parse_input(io::stdin()) .expect("Couldn't parse the input"); + eprintln!("{:?}", ctx.config); + // You can tell the preprocessor to blow up by setting a particular // config value if let Some(table) = ctx.config.get_preprocessor("nop-preprocessor") { @@ -30,6 +33,8 @@ fn handle_preprocessing(args: &ArgMatches) { panic!("Boom!!!1!"); } } + + serde_json::to_writer(io::stdout(), &book).unwrap(); } fn handle_supports(sub_args: &ArgMatches) { diff --git a/src/preprocess/cmd.rs b/src/preprocess/cmd.rs index 2fc14ffc..81f8286e 100644 --- a/src/preprocess/cmd.rs +++ b/src/preprocess/cmd.rs @@ -105,7 +105,7 @@ impl Preprocessor for CmdPreprocessor { Ok(c) => c, Err(e) => { warn!("Unable to create the command for the \"{}\" preprocessor, {}", self.name(), e); - return true; + return false; } }; diff --git a/tests/custom_preprocessors.rs b/tests/custom_preprocessors.rs index d0182e7e..cfc0d1b3 100644 --- a/tests/custom_preprocessors.rs +++ b/tests/custom_preprocessors.rs @@ -32,7 +32,7 @@ fn ask_the_preprocessor_to_blow_up() { let mut md = MDBook::load(&dummy_book).unwrap(); md.with_preprecessor(example()); - md.config.set("preprocess.nop-preprocessor.blow-up", true).unwrap(); + md.config.set("preprocessor.nop-preprocessor.blow-up", true).unwrap(); let got = md.build();