Clean up compiler warnings
This commit is contained in:
parent
3e79d26b22
commit
a70bd4af7f
5 changed files with 13 additions and 11 deletions
|
@ -1,7 +1,6 @@
|
||||||
use pandoc::{self, Pandoc, PandocOutput, PandocError};
|
use pandoc::{self, Pandoc, PandocOutput, PandocError};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use utils::get_exe_dir;
|
use utils::get_exe_dir;
|
||||||
use std::path::PathBuf;
|
|
||||||
use config::{Config, References};
|
use config::{Config, References};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub fn is_valid_csl(csl_name: String) -> bool {
|
||||||
pub fn unpack_csl(csl_name: String) -> PathBuf {
|
pub fn unpack_csl(csl_name: String) -> PathBuf {
|
||||||
let file = get_temp_file();
|
let file = get_temp_file();
|
||||||
let mut csl_temp = File::create(&file).expect("Failed to open temporary 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");
|
csl_temp.write_all(csl_buffer.as_bytes()).expect("Failed to write CSL to temporary file");
|
||||||
return file;
|
return 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 sciter::Element;
|
||||||
use config::Config;
|
use config::Config;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ pub fn head_cleanup(config: Config, input: String) -> Result<String, String> {
|
||||||
destroy_matching(&mut head, "title");
|
destroy_matching(&mut head, "title");
|
||||||
|
|
||||||
let mut meta_charset = Element::create_at("meta", &mut head).unwrap();
|
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);
|
let mut body = get_body(&mut root);
|
||||||
body.set_attribute("class", "content").expect("Failed to set body class");
|
body.set_attribute("class", "content").expect("Failed to set body class");
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use html::{sciter_start, get_html, get_body, find_all};
|
use html::{sciter_start, get_html, get_body, find_all};
|
||||||
use sciter::{Element, Value};
|
|
||||||
use config::Config;
|
use config::Config;
|
||||||
use utils::{resolve_path, path_to_string};
|
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> {
|
pub fn images(config: Config, input: String) -> Result<String, String> {
|
||||||
let mut root = sciter_start(input);
|
let mut root = sciter_start(input);
|
||||||
let mut body = get_body(&mut root);
|
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 {
|
for mut image in images {
|
||||||
let image_src = image.get_attribute("src").expect("Image doesn't have a src");
|
let image_src = image.get_attribute("src").expect("Image doesn't have a src");
|
||||||
let image_path = resolve_path(image_src);
|
let image_path = resolve_path(image_src);
|
||||||
if image_path.exists() && image_path.is_file() {
|
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));
|
return Ok(get_html(root));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use html::{sciter_start, get_html, get_body, find_first};
|
use html::{sciter_start, get_html, get_body};
|
||||||
use sciter::{Element, Value};
|
use sciter::Element;
|
||||||
use config::Config;
|
use config::Config;
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,9 +13,11 @@ fn create_title() -> Element {
|
||||||
pub fn references(config: Config, input: String) -> Result<String, String> {
|
pub fn references(config: Config, input: String) -> Result<String, String> {
|
||||||
let mut root = sciter_start(input);
|
let mut root = sciter_start(input);
|
||||||
let mut body = get_body(&mut root);
|
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() {
|
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));
|
return Ok(get_html(root));
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue