Add specific helper functions
This commit is contained in:
parent
19aaf6fdcd
commit
a7b1e7c466
2 changed files with 10 additions and 2 deletions
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Reference in a new issue