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/head_cleanup.rs

16 lines
583 B
Rust
Raw Normal View History

2017-09-06 18:20:45 +01:00
use html::{sciter_start, get_html, destroy_matching, destroy_at, get_head};
2017-09-13 15:42:47 +01:00
use sciter::Element;
use config::Config;
2017-09-06 19:50:39 +01:00
pub fn head_cleanup(config: Config, input: String) -> Result<String, String> {
let mut root = sciter_start(input);
2017-09-06 17:52:39 +01:00
let mut head = get_head(&mut root);
2017-09-05 21:33:31 +01:00
destroy_matching(&mut head, "meta[content='text/css']");
destroy_matching(&mut head, "style");
destroy_matching(&mut head, "title");
2017-09-13 15:42:47 +01:00
let mut meta_charset = Element::create_at("meta", &mut head).unwrap();
meta_charset.set_attribute("charset", "UTF-8");
2017-09-05 21:33:31 +01:00
return Ok(get_html(root));
}