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

20 lines
751 B
Rust
Raw Normal View History

2017-12-21 16:27:55 +00:00
use html::{sciter_start, get_html, get_head};
2017-11-26 21:46:28 +00:00
use sciter::Element;
use config::Config;
use assets;
fn create_css_element(style: String) -> Element {
let mut style_tag = Element::with_text("style", &style).unwrap();
2017-12-21 16:27:55 +00:00
style_tag.set_attribute("type", "text/css").expect(&format!("Failed to set CSS mimetype for {}", style));
style_tag.set_attribute("media", "all").expect(&format!("Failed to set CSS media type for {}", style));
2017-11-26 21:46:28 +00:00
return style_tag;
}
pub fn static_files(_: Config, input: String) -> Result<String, String> {
let mut root = sciter_start(input);
let mut head = get_head(&mut root);
2017-12-21 16:27:55 +00:00
head.append(&create_css_element(assets::get("style.css"))).expect("Failed to inject CSS file");
2017-11-26 21:46:28 +00:00
return Ok(get_html(root));
}