djoc 0.1.0

The Djot document compiler
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::{io, path::Path};

use hayagriva::Entry;

use crate::{utils::find_root, walk::Walker};

pub fn get_bib_entries<P: AsRef<Path>>(path: Option<P>) -> io::Result<Vec<Entry>> {
    let bibtex_content = match path {
        Some(path) => Walker::new(path)?.filter_extensions(&["bib", "bibtex"]),
        _ => Walker::new(".")?.filter_extensions(&["bib", "bibtex"]),
    }
    .map(std::fs::read_to_string)
    .collect::<Result<String, io::Error>>()?;

    // TODO: Handle error(s)
    Ok(hayagriva::io::from_biblatex_str(&bibtex_content).unwrap())
}