| Crates.io | biblike |
| lib.rs | biblike |
| version | 0.1.0 |
| created_at | 2025-05-11 22:08:42.880913+00 |
| updated_at | 2025-05-11 22:08:42.880913+00 |
| description | Convert the citation to any format. |
| homepage | |
| repository | https://github.com/hifa-lang/biblike.git |
| max_upload_size | |
| id | 1669797 |
| size | 26,729 |
Convert the citation to any format.
use biblatex::{Bibliography, Entry};
use biblike::CitationManager;
let mut manager = CitationManager::open("tests/references.bib").unwrap();
let entry_fn = |key: &str, number: usize, entry: Option<&Entry>| -> String {
if let Some(entry) = entry {
let formatted = format!(
"{} {}",
entry.author().unwrap()[0].name,
entry.title().unwrap()[0].v.get()
);
format!("[{}] {}\n", number, formatted)
} else {
format!("[{}] [Missing entry for key: {}]\n", number, key)
}
};
let format_content = manager.render_content(
"This is a test content \\cite{sample1999article} with \\cite{sample2099book, sample2025web}.\nSecond line \\cite{sample1999article}\n References\n\\printbibliography",
"\\printbibliography",
entry_fn,
);
assert_eq!(
format_content,
"This is a test content [1] with [2], [3].\nSecond line [1]\n References\n[1] Suzuki A Completely Fictional Study on the Effects of Imaginary Numbers\n[2] Yamada This is a Sample Book Title\n[3] Corporation Sample Blog Post: Talking to Imaginary Friends\n"
);