Add LinkPreprocessor::new constructor
This commit is contained in:
parent
144358bec6
commit
9c922cf26b
|
@ -224,9 +224,8 @@ impl MDBook {
|
|||
|
||||
let temp_dir = TempDir::new("mdbook")?;
|
||||
|
||||
let replace_all_preprocessor = preprocess::links::LinkPreprocessor {
|
||||
src_dir: self.source_dir(),
|
||||
};
|
||||
let src_dir = self.source_dir();
|
||||
let replace_all_preprocessor = preprocess::links::LinkPreprocessor::new(src_dir);
|
||||
|
||||
replace_all_preprocessor.run(&mut self.book)?;
|
||||
|
||||
|
@ -341,11 +340,9 @@ fn determine_preprocessors(md_book: &MDBook) -> Vec<Box<Preprocessor>> {
|
|||
for key in preprocess_array.iter() {
|
||||
match key.as_str() {
|
||||
Some(key) if key == "links" => {
|
||||
let link_preprocessor = preprocess::links::LinkPreprocessor {
|
||||
src_dir: md_book.source_dir(),
|
||||
};
|
||||
|
||||
preprocessors.push(Box::new(link_preprocessor ))
|
||||
let src_dir = md_book.source_dir();
|
||||
let link_preprocessor = preprocess::links::LinkPreprocessor::new(src_dir);
|
||||
preprocessors.push(Box::new(link_preprocessor))
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -353,10 +350,8 @@ fn determine_preprocessors(md_book: &MDBook) -> Vec<Box<Preprocessor>> {
|
|||
}
|
||||
|
||||
if preprocessors.is_empty() {
|
||||
let link_preprocessor = preprocess::links::LinkPreprocessor {
|
||||
src_dir: md_book.source_dir(),
|
||||
};
|
||||
|
||||
let src_dir = md_book.source_dir();
|
||||
let link_preprocessor = preprocess::links::LinkPreprocessor::new(src_dir);
|
||||
preprocessors.push(Box::new(link_preprocessor))
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,13 @@ use book::{Book, BookItem};
|
|||
const ESCAPE_CHAR: char = '\\';
|
||||
|
||||
pub struct LinkPreprocessor {
|
||||
pub src_dir: PathBuf
|
||||
src_dir: PathBuf
|
||||
}
|
||||
|
||||
impl LinkPreprocessor {
|
||||
pub fn new<P: Into<PathBuf>>(src_dir: P) -> Self {
|
||||
LinkPreprocessor { src_dir: src_dir.into() }
|
||||
}
|
||||
}
|
||||
|
||||
impl Preprocessor for LinkPreprocessor {
|
||||
|
|
Loading…
Reference in New Issue