Add references title
This commit is contained in:
parent
1313c34c7d
commit
e5c3f20dd3
2 changed files with 29 additions and 2 deletions
|
@ -3,7 +3,13 @@ use config::Config;
|
|||
mod head_cleanup;
|
||||
mod strip_blank;
|
||||
mod rebrand;
|
||||
mod references;
|
||||
|
||||
|
||||
pub const PROCESSORS: [fn(Config, String) -> Result<String, String>; 3] =
|
||||
[head_cleanup::head_cleanup, rebrand::rebrand, strip_blank::strip_blank];
|
||||
pub const PROCESSORS: [fn(Config, String) -> Result<String, String>; 4] =
|
||||
[
|
||||
head_cleanup::head_cleanup,
|
||||
rebrand::rebrand,
|
||||
references::references,
|
||||
strip_blank::strip_blank,
|
||||
];
|
||||
|
|
21
src/processors/references.rs
Normal file
21
src/processors/references.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
use html::{sciter_start, get_html, get_body, find_first};
|
||||
use sciter::{Element, Value};
|
||||
use config::Config;
|
||||
|
||||
|
||||
fn create_title() -> Element {
|
||||
let mut references_title = Element::with_text("h1", "References").unwrap();
|
||||
references_title.set_attribute("class", "references-title").unwrap();
|
||||
return references_title;
|
||||
}
|
||||
|
||||
|
||||
pub fn references(config: Config, input: String) -> Result<String, String> {
|
||||
let mut root = sciter_start(input);
|
||||
let mut body = get_body(&mut root);
|
||||
let mut possible_references = body.find_first("div#refs").expect("Failed to get refs");
|
||||
if possible_references.is_some() {
|
||||
body.insert(possible_references.unwrap().index(), &create_title());
|
||||
}
|
||||
return Ok(get_html(root));
|
||||
}
|
Reference in a new issue