diff --git a/src/build/pandoc.rs b/src/build/pandoc.rs index bba26d0..f5d7ace 100644 --- a/src/build/pandoc.rs +++ b/src/build/pandoc.rs @@ -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}; diff --git a/src/config/csl.rs b/src/config/csl.rs index 49221ec..6fc3c8f 100644 --- a/src/config/csl.rs +++ b/src/config/csl.rs @@ -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; } diff --git a/src/processors/head_cleanup.rs b/src/processors/head_cleanup.rs index b44b793..d44021f 100644 --- a/src/processors/head_cleanup.rs +++ b/src/processors/head_cleanup.rs @@ -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 { 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"); diff --git a/src/processors/images.rs b/src/processors/images.rs index 40a1118..46c3068 100644 --- a/src/processors/images.rs +++ b/src/processors/images.rs @@ -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 { 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)); diff --git a/src/processors/references.rs b/src/processors/references.rs index 8c33faf..20f1445 100644 --- a/src/processors/references.rs +++ b/src/processors/references.rs @@ -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 { 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)); }