|
|
@ -36,7 +36,7 @@ impl Preprocessor for Template {
|
|
|
|
.map(|dir| src_dir.join(dir))
|
|
|
|
.map(|dir| src_dir.join(dir))
|
|
|
|
.expect("All book items have a parent");
|
|
|
|
.expect("All book items have a parent");
|
|
|
|
|
|
|
|
|
|
|
|
let content = replace(&chapter.content, base, source, 0);
|
|
|
|
let content = replace_template(&chapter.content, base, source, 0);
|
|
|
|
chapter.content = content;
|
|
|
|
chapter.content = content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -50,7 +50,7 @@ impl Preprocessor for Template {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn replace<P1, P2>(chapter_content: &str, base: P1, source: P2, depth: usize) -> String
|
|
|
|
fn replace_template<P1, P2>(chapter_content: &str, base: P1, source: P2, depth: usize) -> String
|
|
|
|
where
|
|
|
|
where
|
|
|
|
P1: AsRef<Path>,
|
|
|
|
P1: AsRef<Path>,
|
|
|
|
P2: AsRef<Path>,
|
|
|
|
P2: AsRef<Path>,
|
|
|
@ -68,7 +68,12 @@ where
|
|
|
|
Ok(new_content) => {
|
|
|
|
Ok(new_content) => {
|
|
|
|
if depth < MAX_LINK_NESTED_DEPTH {
|
|
|
|
if depth < MAX_LINK_NESTED_DEPTH {
|
|
|
|
if let Some(rel_path) = link.link_type.relative_path(path) {
|
|
|
|
if let Some(rel_path) = link.link_type.relative_path(path) {
|
|
|
|
replaced.push_str(&replace(&new_content, rel_path, source, depth + 1));
|
|
|
|
replaced.push_str(&replace_template(
|
|
|
|
|
|
|
|
&new_content,
|
|
|
|
|
|
|
|
rel_path,
|
|
|
|
|
|
|
|
source,
|
|
|
|
|
|
|
|
depth + 1,
|
|
|
|
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
replaced.push_str(&new_content);
|
|
|
|
replaced.push_str(&new_content);
|
|
|
|
}
|
|
|
|
}
|
|
|
|