-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implementing preprocessors #532
Changes from all commits
01df904
cad76a9
9668110
f282a55
12815fe
4cc708e
144358b
9c922cf
b98ed3f
08027b8
b599956
4177288
f2d7b70
90fa1b4
47cc571
0d62578
80a20eb
1136f67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,25 @@ | ||
pub mod links; | ||
pub use self::links::LinkPreprocessor; | ||
|
||
mod links; | ||
|
||
use book::Book; | ||
use config::Config; | ||
use errors::*; | ||
|
||
use std::path::PathBuf; | ||
|
||
pub struct PreprocessorContext { | ||
pub root: PathBuf, | ||
pub config: Config, | ||
} | ||
|
||
impl PreprocessorContext { | ||
pub fn new(root: PathBuf, config: Config) -> Self { | ||
PreprocessorContext { root, config } | ||
} | ||
} | ||
|
||
pub trait Preprocessor { | ||
fn name(&self) -> &str; | ||
fn run(&self, ctx: &PreprocessorContext, book: &mut Book) -> Result<()>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm tossing up whether to include the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's helpful to distinguish the fact that you only expect the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yeah that's a good point. I completely forgot the |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that we're not mutating the original book here and instead preprocessing its clone 👍