Add specific helper functions

This commit is contained in:
Jake Howard 2017-09-06 17:52:39 +01:00
parent 19aaf6fdcd
commit a7b1e7c466
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 10 additions and 2 deletions

View file

@ -1,10 +1,10 @@
use renderers::{sciter_start, get_html, destroy_matching, destroy_at, find_first};
use renderers::{sciter_start, get_html, destroy_matching, destroy_at, get_head};
use config::Config;
pub fn html_cleanup(config: Config, input: String) -> Result<String, String> {
let mut root = sciter_start(input);
let mut head = find_first(&mut root, "head");
let mut head = get_head(&mut root);
destroy_at(&mut head, 4); // Sciter doesnt like finding this style tag for some reason
destroy_matching(&mut head, "meta[content='text/css']");
destroy_matching(&mut head, "style");

View file

@ -51,3 +51,11 @@ fn destroy_matching(root: &mut Element, selector: &str) {
ele.destroy().expect("Failed to delete");
}
}
fn get_head(root: &mut Element) -> Element {
return find_first(root, "head");
}
fn get_body(root: &mut Element) -> Element {
return find_first(root, "body");
}