use crate::fields::BseReferenceEntry;
pub fn write_bib(key: &str, ref_entry: &BseReferenceEntry) -> String {
let mut s = String::new();
s += &format!("@{}{{{},\n", ref_entry.entry_type, key);
let mut entry_lines: Vec<String> = Vec::new();
for (k, v) in &ref_entry.fields {
if k == "authors" {
entry_lines.push(format!(" author = {{{}}}", v.to_vec().join(" and ")));
} else if k == "editors" {
entry_lines.push(format!(" editor = {{{}}}", v.to_vec().join(" and ")));
} else if let Some(val) = v.first() {
entry_lines.push(format!(" {} = {{{}}}", k, val));
}
}
s += &entry_lines.join(",\n");
s += "\n}";
s
}