Skip to content

Commit a8fba20

Browse files
committed
Support mdBook preprocessors for TRPL in rustbook
`rust-lang/book` recently added two mdBook preprocessors. Enable `rustbook` to use those preprocessors for books where they are requested by the `book.toml` by adding the preprocessors as path dependencies, and ignoring them where they are not requested, i.e. by all the books other than TRPL at present.
1 parent f0038a7 commit a8fba20

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/tools/rustbook/src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ use clap::{arg, ArgMatches, Command};
88
use mdbook::errors::Result as Result3;
99
use mdbook::MDBook;
1010

11+
use mdbook_trpl_listing::TrplListing;
12+
use mdbook_trpl_note::TrplNote;
13+
1114
fn main() {
1215
let crate_version = concat!("v", crate_version!());
1316
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
@@ -67,6 +70,14 @@ pub fn build(args: &ArgMatches) -> Result3<()> {
6770
book.config.build.build_dir = dest_dir.into();
6871
}
6972

73+
if book.config.get_preprocessor("trpl-note").is_some() {
74+
book.with_preprocessor(TrplNote);
75+
}
76+
77+
if book.config.get_preprocessor("trpl-listing").is_some() {
78+
book.with_preprocessor(TrplListing);
79+
}
80+
7081
book.build()?;
7182

7283
Ok(())

0 commit comments

Comments
 (0)