@@ -360,16 +360,20 @@ fn determine_preprocessors(config: &Config) -> Result<Vec<Box<Preprocessor>>> {
360
360
. and_then ( |value| value. as_table ( ) )
361
361
. map ( |table| table. keys ( ) ) ;
362
362
363
+ let mut preprocessors = if config. build . use_default_preprocessors {
364
+ default_preprocessors ( )
365
+ } else {
366
+ Vec :: new ( )
367
+ } ;
368
+
363
369
let preprocessor_keys = match preprocessor_keys {
364
370
Some ( keys) => keys,
365
371
// If no preprocessor field is set, default to the LinkPreprocessor and
366
372
// IndexPreprocessor. This allows you to disable default preprocessors
367
373
// by setting "preprocess" to an empty list.
368
- None => return Ok ( default_preprocessors ( ) ) ,
374
+ None => return Ok ( preprocessors ) ,
369
375
} ;
370
376
371
- let mut preprocessors: Vec < Box < Preprocessor > > = Vec :: new ( ) ;
372
-
373
377
for key in preprocessor_keys {
374
378
match key. as_ref ( ) {
375
379
"links" => preprocessors. push ( Box :: new ( LinkPreprocessor :: new ( ) ) ) ,
@@ -477,6 +481,16 @@ mod tests {
477
481
assert_eq ! ( got. as_ref( ) . unwrap( ) [ 1 ] . name( ) , "index" ) ;
478
482
}
479
483
484
+ #[ test]
485
+ fn use_default_preprocessors_works ( ) {
486
+ let mut cfg = Config :: default ( ) ;
487
+ cfg. build . use_default_preprocessors = false ;
488
+
489
+ let got = determine_preprocessors ( & cfg) . unwrap ( ) ;
490
+
491
+ assert_eq ! ( got. len( ) , 0 ) ;
492
+ }
493
+
480
494
#[ test]
481
495
fn config_complains_if_unimplemented_preprocessor ( ) {
482
496
let cfg_str: & ' static str = r#"
0 commit comments