This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
md-pdf-rs/src/processors/references.rs

24 lines
769 B
Rust
Raw Normal View History

2017-09-24 18:46:19 +01:00
use html::{sciter_start, get_html, get_body};
use sciter::Element;
2017-09-17 21:16:21 +01:00
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);
2017-09-24 18:46:19 +01:00
let possible_references = body.find_first("div#refs").expect("Failed to get refs");
2017-09-17 21:16:21 +01:00
if possible_references.is_some() {
2017-09-24 18:46:19 +01:00
body.insert(possible_references.unwrap().index(), &create_title()).expect(
"Failed to add references title"
);
2017-09-17 21:16:21 +01:00
}
return Ok(get_html(root));
}