biblike

Crates.iobiblike
lib.rsbiblike
version0.1.0
created_at2025-05-11 22:08:42.880913+00
updated_at2025-05-11 22:08:42.880913+00
descriptionConvert the citation to any format.
homepage
repositoryhttps://github.com/hifa-lang/biblike.git
max_upload_size
id1669797
size26,729
Kazuki Kurota (kurotakazuki)

documentation

https://docs.rs/biblike/

README

BibLike

Convert the citation to any format.

Crate API

Example

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"
);
Commit count: 0

cargo fmt