2018-01-08 04:05:57 +08:00
|
|
|
pub use self::links::LinkPreprocessor;
|
|
|
|
|
|
|
|
mod links;
|
2018-01-07 23:24:37 +08:00
|
|
|
|
2018-01-08 00:21:46 +08:00
|
|
|
use book::Book;
|
2018-01-17 17:44:52 +08:00
|
|
|
use config::Config;
|
2018-01-08 00:21:46 +08:00
|
|
|
use errors::*;
|
|
|
|
|
2018-01-08 04:05:57 +08:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
pub struct PreprocessorContext {
|
2018-01-17 17:44:52 +08:00
|
|
|
pub root: PathBuf,
|
|
|
|
pub config: Config,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PreprocessorContext {
|
|
|
|
pub fn new(root: PathBuf, config: Config) -> Self {
|
|
|
|
PreprocessorContext { root, config }
|
|
|
|
}
|
2018-01-08 04:05:57 +08:00
|
|
|
}
|
2018-01-07 23:24:37 +08:00
|
|
|
|
2018-01-08 00:21:46 +08:00
|
|
|
pub trait Preprocessor {
|
2018-01-16 06:54:14 +08:00
|
|
|
fn name(&self) -> &str;
|
2018-01-08 04:05:57 +08:00
|
|
|
fn run(&self, ctx: &PreprocessorContext, book: &mut Book) -> Result<()>;
|
2018-01-07 23:24:37 +08:00
|
|
|
}
|