Skip to content

hifa-lang/biblike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
);

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt

Stars

Watchers

Forks

Packages

No packages published