archive
/
md-pdf-rs
Archived
1
Fork 0

Reduce compiler warnings

This commit is contained in:
Jake Howard 2017-09-05 21:36:41 +01:00
parent 714e944d93
commit 19aaf6fdcd
Signed by: jake
GPG Key ID: 57AFB45680EDD477
5 changed files with 8 additions and 13 deletions

View File

@ -5,7 +5,7 @@ use config::Config;
pub fn build_input(config: Config, input: String) -> Result<String, String> {
let html = try!(pandoc::render(config.clone(), input));
let html = try!(pandoc::render(input));
let rendered = try!(render::render(config.clone(), html));
return Ok(rendered);
}

View File

@ -1,10 +1,9 @@
use config::Config;
use pandoc::{self, Pandoc, PandocOutput, PandocError};
use std::env::{current_dir, current_exe};
use std::path::PathBuf;
use std::env::current_exe;
use std::error::Error;
fn execute_pandoc(config: Config, input: String) -> Result<PandocOutput, PandocError> {
fn execute_pandoc(input: String) -> Result<PandocOutput, PandocError> {
let mut renderer = Pandoc::new();
renderer.set_output_format(pandoc::OutputFormat::Html, vec![]);
renderer.set_input_format(pandoc::InputFormat::Markdown, vec![]);
@ -17,8 +16,8 @@ fn execute_pandoc(config: Config, input: String) -> Result<PandocOutput, PandocE
}
pub fn render(config: Config, input: String) -> Result<String, String> {
let output = execute_pandoc(config, input);
pub fn render(input: String) -> Result<String, String> {
let output = execute_pandoc(input);
if output.is_err() {
return Err(output.err().unwrap().description().into());
}

View File

@ -1,5 +1,4 @@
use config::Config;
use std::char;
use renderers::html_cleanup::html_cleanup;
use renderers::strip_blank::strip_blank;

View File

@ -1,14 +1,11 @@
use renderers::{sciter_start, get_html, destroy_matching, destroy_at, find_first};
use config::Config;
use sciter::{Window};
use std::ops::Deref;
use std::rc::Rc;
pub fn html_cleanup(config: Config, input: String) -> Result<String, String> {
let mut root = sciter_start(input);
let mut head = find_first(&mut root, "head");
destroy_at(&mut head, 4); // Sciter doesnt like finding this style tag for some reason
destroy_at(&mut head, 4); // Sciter doesnt like finding this style tag for some reason
destroy_matching(&mut head, "meta[content='text/css']");
destroy_matching(&mut head, "style");
destroy_matching(&mut head, "title");

View File

@ -16,7 +16,7 @@ fn sciter_start(source: String) -> Element {
}
fn get_html(element: Element) -> String {
element.update(true);
element.update(true).expect("Failed to update");
return String::from_utf8(element.get_html(true)).expect(&format!(
"Failed to get HTML from {}.",
element.get_tag()