archive
/
md-pdf-rs
Archived
1
Fork 0

References are meant to be optional...

This commit is contained in:
Jake Howard 2017-09-10 19:09:21 +01:00
parent 823c8bc1ad
commit 1b395a8f60
Signed by: jake
GPG Key ID: 57AFB45680EDD477
2 changed files with 7 additions and 4 deletions

View File

@ -16,7 +16,7 @@ pub struct Config {
pub output: HashMap<String, PathBuf>, pub output: HashMap<String, PathBuf>,
pub title: String, pub title: String,
pub verbosity: u64, pub verbosity: u64,
pub references: References pub references: Option<References>
} }
#[derive(Debug, Serialize, Deserialize, Default, Clone)] #[derive(Debug, Serialize, Deserialize, Default, Clone)]

View File

@ -58,10 +58,13 @@ pub fn get_output_files(conf: Value) -> HashMap<String, PathBuf> {
return output_map; return output_map;
} }
pub fn get_references(config: Value) -> References { pub fn get_references(config: Value) -> Option<References> {
if config.get("references").is_none() {
return None;
}
let references = config.get("references").unwrap(); let references = config.get("references").unwrap();
return References { return Some(References {
bibliography: resolve_path(references.get("bibliography").unwrap().as_str().unwrap().into()), bibliography: resolve_path(references.get("bibliography").unwrap().as_str().unwrap().into()),
csl: unpack_csl(references.get("csl").unwrap().as_str().unwrap().into()) csl: unpack_csl(references.get("csl").unwrap().as_str().unwrap().into())
} });
} }