use std::fs;
use std::path::Path;
use citum_schema::InputBibliography;
use crate::RefsError;
pub fn parse_biblatex_str(src: &str) -> Result<InputBibliography, RefsError> {
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()
})
}
pub fn load_biblatex(path: &Path) -> Result<InputBibliography, RefsError> {
let src = fs::read_to_string(path)?;
parse_biblatex_str(&src)
}