Add an actual renderer to cleanup pandocs HTML
This commit is contained in:
parent
be039aa735
commit
0a943bbfa5
4 changed files with 17 additions and 9 deletions
|
@ -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);
|
||||
|
|
13
src/renderers/html_cleanup.rs
Normal file
13
src/renderers/html_cleanup.rs
Normal 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);
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
Reference in a new issue