archive
/
md-pdf-rs
Archived
1
Fork 0

Create stub renderer for sciter, just to check it works

This commit is contained in:
Jake Howard 2017-09-01 09:08:44 +01:00
parent 24bb775f25
commit 1e5a3ccab6
Signed by: jake
GPG Key ID: 57AFB45680EDD477
4 changed files with 30 additions and 4 deletions

View File

@ -1,9 +1,6 @@
use config::Config;
fn stub(config: Config, input: String) -> Result<String, String> {
return Ok(input);
}
use renderers::stub;
pub fn render(config: Config, input: String) -> Result<String, String> {
let mut rendered_input = input;

View File

@ -18,6 +18,7 @@ mod input;
mod utils;
mod build;
mod output;
mod renderers;
#[cfg(test)]
mod tests;

10
src/renderers/mod.rs Normal file
View File

@ -0,0 +1,10 @@
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);
}

18
src/renderers/sciter.rs Normal file
View File

@ -0,0 +1,18 @@
use sciter::{Window, Host, Element};
use std::rc::Rc;
use std::ops::Deref;
fn get_root(frame: Window) -> Element {
return frame.get_host().deref().get_root().expect("Failed to get root of window");
}
pub fn sciter_start(source: String) -> Element {
let mut frame = Window::new();
frame.load_html(&source.as_bytes(), None);
return get_root(frame);
}
pub fn get_html(element: Element) -> String {
return String::from_utf8(element.get_html(true)).expect("Failed to get HTML from element");
}