-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add citations and bibliography support
- Loading branch information
Showing
6 changed files
with
66 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
use std::{io, path::Path}; | ||
use std::io; | ||
|
||
use hayagriva::Entry; | ||
use hayagriva::{io::from_biblatex_str, Entry}; | ||
|
||
use crate::{utils::find_root, walk::Walker}; | ||
use crate::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>>()?; | ||
pub fn get_bib_entries() -> io::Result<Vec<Entry>> { | ||
let bibtex_content = Walker::new(".")? | ||
.max_nesting(5) | ||
.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()) | ||
let entries = from_biblatex_str(&bibtex_content).unwrap(); | ||
Ok(entries) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mod bibliography; | ||
mod csl; | ||
// mod csl; | ||
|
||
pub use bibliography::get_bib_entries; | ||
pub use csl::get_csl; | ||
// pub use csl::get_csl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
//! ``` | ||
mod author; | ||
mod bib; | ||
mod builder; | ||
mod date; | ||
mod document; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters