Add an actual renderer to cleanup pandocs HTML

This commit is contained in:
Jake Howard 2017-09-01 13:59:27 +01:00
parent be039aa735
commit 0a943bbfa5
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 17 additions and 9 deletions

View file

@ -1,10 +1,10 @@
use config::Config;
use renderers::stub;
use renderers::html_cleanup::html_cleanup;
pub fn render(config: Config, input: String) -> Result<String, String> {
let mut rendered_input = input;
for renderer in vec![stub] {
for renderer in vec![html_cleanup] {
rendered_input = try!(renderer(config.clone(), rendered_input));
}
return Ok(rendered_input);

View file

@ -0,0 +1,13 @@
use renderers::helpers::{sciter_start, get_html};
use config::Config;
pub fn html_cleanup(config: Config, input: String) -> Result<String, String> {
let mut root = sciter_start(input);
root.find_first("meta[content='text/css']").unwrap().unwrap().destroy().unwrap();
root.find_first("style").unwrap().unwrap().destroy().unwrap();
root.find_first("title").unwrap().unwrap().destroy().unwrap();
let html = get_html(root);
return Ok(html);
}

View file

@ -1,10 +1,5 @@
use config::Config;
pub mod sciter;
pub fn stub(config: Config, input: String) -> Result<String, String> {
let root = sciter::sciter_start(input);
let html = sciter::get_html(root);
return Ok(html);
}
mod helpers;
pub mod html_cleanup;