mirror of
https://git.pumpin.online/funkpower/catena.git
synced 2026-10-23 11:17:13 +00:00
idnorm and bibfetch: an identifier read, and a register asked
This commit is contained in:
@@ -176,6 +176,12 @@ pub fn identify(name: &str, bytes: &[u8]) -> Doc {
|
||||
booksniff::sniff(&bytes, name)
|
||||
}
|
||||
|
||||
/// Read an identifier — a DOI, ISSN, ISBN or arXiv id — out of whatever it
|
||||
/// arrived wrapped in.
|
||||
pub fn parse_identifier(text: &str) -> Option<idnorm::Identifier> {
|
||||
idnorm::parse(text)
|
||||
}
|
||||
|
||||
/// The series a title belongs to, and which volume of it this is.
|
||||
pub fn series_of(title: &str, author: Option<&str>) -> Option<seriesof::Proposal> {
|
||||
seriesof::series_of(title, author)
|
||||
@@ -237,6 +243,13 @@ mod tests {
|
||||
assert_eq!(channel_named("lexical"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_identifier_comes_back_normalised() {
|
||||
let found = parse_identifier("https://doi.org/10.1000/182").expect("an identifier");
|
||||
assert_eq!(found.id, "10.1000/182");
|
||||
assert_eq!(parse_identifier("hello"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_series_comes_back_the_same_as_the_library_reads_it() {
|
||||
let found = series_of("The Philokalia Vol 3", None).expect("a series");
|
||||
|
||||
Reference in New Issue
Block a user