Clean up compiler warnings

This commit is contained in:
Jake Howard 2017-09-24 18:46:19 +01:00
parent 3e79d26b22
commit a70bd4af7f
Signed by: jake
GPG key ID: 57AFB45680EDD477
5 changed files with 13 additions and 11 deletions

View file

@ -1,7 +1,6 @@
use pandoc::{self, Pandoc, PandocOutput, PandocError};
use std::error::Error;
use utils::get_exe_dir;
use std::path::PathBuf;
use config::{Config, References};

View file

@ -36,7 +36,7 @@ pub fn is_valid_csl(csl_name: String) -> bool {
pub fn unpack_csl(csl_name: String) -> PathBuf {
let file = get_temp_file();
let mut csl_temp = File::create(&file).expect("Failed to open temporary file");
let mut csl_buffer = get_csl_data(csl_name).unwrap();
let csl_buffer = get_csl_data(csl_name).unwrap();
csl_temp.write_all(csl_buffer.as_bytes()).expect("Failed to write CSL to temporary file");
return file;
}

View file

@ -1,4 +1,4 @@
use html::{sciter_start, get_html, destroy_matching, destroy_at, get_head, get_body};
use html::{sciter_start, get_html, destroy_matching, get_head, get_body};
use sciter::Element;
use config::Config;
@ -11,7 +11,7 @@ pub fn head_cleanup(config: Config, input: String) -> Result<String, String> {
destroy_matching(&mut head, "title");
let mut meta_charset = Element::create_at("meta", &mut head).unwrap();
meta_charset.set_attribute("charset", "UTF-8");
meta_charset.set_attribute("charset", "UTF-8").expect("Failed to set charset");
let mut body = get_body(&mut root);
body.set_attribute("class", "content").expect("Failed to set body class");

View file

@ -1,5 +1,4 @@
use html::{sciter_start, get_html, get_body, find_all};
use sciter::{Element, Value};
use config::Config;
use utils::{resolve_path, path_to_string};
@ -7,12 +6,14 @@ use utils::{resolve_path, path_to_string};
pub fn images(config: Config, input: String) -> Result<String, String> {
let mut root = sciter_start(input);
let mut body = get_body(&mut root);
let mut images = find_all(&mut body, "img[src]");
let images = find_all(&mut body, "img[src]");
for mut image in images {
let image_src = image.get_attribute("src").expect("Image doesn't have a src");
let image_path = resolve_path(image_src);
if image_path.exists() && image_path.is_file() {
image.set_attribute("src", path_to_string(&image_path.canonicalize().unwrap()));
image
.set_attribute("src", path_to_string(&image_path.canonicalize().unwrap()))
.expect("Failed to set image attribute");
}
}
return Ok(get_html(root));

View file

@ -1,5 +1,5 @@
use html::{sciter_start, get_html, get_body, find_first};
use sciter::{Element, Value};
use html::{sciter_start, get_html, get_body};
use sciter::Element;
use config::Config;
@ -13,9 +13,11 @@ fn create_title() -> Element {
pub fn references(config: Config, input: String) -> Result<String, String> {
let mut root = sciter_start(input);
let mut body = get_body(&mut root);
let mut possible_references = body.find_first("div#refs").expect("Failed to get refs");
let possible_references = body.find_first("div#refs").expect("Failed to get refs");
if possible_references.is_some() {
body.insert(possible_references.unwrap().index(), &create_title());
body.insert(possible_references.unwrap().index(), &create_title()).expect(
"Failed to add references title"
);
}
return Ok(get_html(root));
}