use std::fs;
use std::path::Path;
use citum_schema::InputBibliography;
use crate::RefsError;
pub fn load_biblatex(path: &Path) -> Result<InputBibliography, RefsError> {
let src = fs::read_to_string(path)?;
let bibliography = ::biblatex::Bibliography::parse(&src)
.map_err(|e| RefsError::ParseError("BibLaTeX".to_string(), e.to_string()))?;
let references = bibliography
.iter()
.map(crate::biblatex::input_reference_from_biblatex)
.collect();
Ok(InputBibliography {
references,
..Default::default()
})
}