archive
/
md-pdf-rs
Archived
1
Fork 0

Add struct for storing references data

This commit is contained in:
Jake Howard 2017-09-10 18:51:40 +01:00
parent 3066ad2070
commit 823c8bc1ad
Signed by: jake
GPG Key ID: 57AFB45680EDD477
2 changed files with 20 additions and 2 deletions

View File

@ -15,7 +15,14 @@ pub struct Config {
pub input: Vec<PathBuf>,
pub output: HashMap<String, PathBuf>,
pub title: String,
pub verbosity: u64
pub verbosity: u64,
pub references: References
}
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
pub struct References {
pub bibliography: PathBuf,
pub csl: PathBuf
}
impl Config {
@ -24,6 +31,7 @@ impl Config {
input: read::get_input_files(raw.clone()),
output: read::get_output_files(raw.clone()),
title: read::get_string(&raw, "title"),
references: read::get_references(raw.clone()),
..Default::default()
};
}

View File

@ -5,8 +5,10 @@ use std::io::Read;
use serde_yaml::Value;
use std::collections::HashMap;
use config::csl::unpack_csl;
use config::consts;
use utils::result_override;
use config::References;
use utils::{result_override, resolve_path};
fn get_config_path() -> PathBuf {
let mut working_dir = current_dir().unwrap();
@ -55,3 +57,11 @@ pub fn get_output_files(conf: Value) -> HashMap<String, PathBuf> {
}
return output_map;
}
pub fn get_references(config: Value) -> References {
let references = config.get("references").unwrap();
return References {
bibliography: resolve_path(references.get("bibliography").unwrap().as_str().unwrap().into()),
csl: unpack_csl(references.get("csl").unwrap().as_str().unwrap().into())
}
}