summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bryan <michaelfbryan@gmail.com>2018-09-16 23:28:01 +0800
committerMichael Bryan <michaelfbryan@gmail.com>2018-09-16 23:28:01 +0800
commit1d72cea972bcf813ce50d6be273f11cc3b5909ce (patch)
tree1b015b69e3be31af81e704ca1a42a0542e10f2a6
parent1aa1194d798b1e8ab5788bb527f968981e7b9ca2 (diff)
The example preprocessor works
-rw-r--r--examples/nop-preprocessor.rs7
-rw-r--r--src/preprocess/cmd.rs2
-rw-r--r--tests/custom_preprocessors.rs2
3 files changed, 8 insertions, 3 deletions
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();