Skip to main content

Module refs

Module refs 

Source
Expand description

Bibliography input adapters per ADR-0030.

Parses three input shapes into an iterator of Refs with optional entry_key provenance back to the source bibliography:

  • Plain refs: one doi:… / arxiv:… / bare-DOI / bare-arXiv id per line, with #-prefixed comments and blank lines tolerated. The existing doiget batch <refs.txt> shape.
  • CSL-JSON: a JSON array of entries with id (citation key), DOI, and optionally archivePrefix = "arXiv" + eprint fields. Parsed via the workspace’s existing serde_json — no new dependency.
  • BibTeX / BibLaTeX (.bib): parsed via the biblatex crate (ADR-0030 D2). One @entrytype{KEY, …} per entry; the doi field is preferred, falling back to an arXiv eprint.

Identifier-pick priority per ADR-0030 D3: doi > arxiv > pmid. A PMID / PMCID entry is reported here as UnsupportedIdentifier and turned into the DOI PubMed lists for it by crate::pubmed::resolve_entries (#500, ADR-0061) – a request, so not in this pure parser. There is no Ref::Pmid: the DOI is the identity.

Parse-error policy per ADR-0030 D5: a single entry’s failure is captured per-entry and does NOT abort the whole batch. The caller decides whether to skip-and-warn (default) or fail-closed (--strict).

Structs§

ParsedEntry
One successfully-parsed bibliography entry.

Enums§

Format
Input-shape discriminator per ADR-0030 D4.
ParseError
Why a single bibliography entry failed to produce a Ref.

Functions§

detect_format
Detect the input format per ADR-0030 D4.
parse_bibtex
Parse a BibTeX / BibLaTeX document via the biblatex crate (ADR-0030 D2). One @entrytype{KEY, …} produces one entry; entry_key is the citation key verbatim.
parse_csl_json
Parse a CSL-JSON document — a JSON array of objects, each with at least an id (citation key) and one of DOI, or archivePrefix
parse_input
Parse text per format, dispatching to the matching shape parser. path is consulted only when format == Format::Auto to drive detect_format.
parse_plain_refs
Parse plain refs — the existing batch input format. One ref per non-blank, non-comment line. entry_key is always None for this shape; plain refs have no citation-key concept.
unsupported_identifier_claim
The claim ParseError::UnsupportedIdentifier makes, without the entry {entry_key:?} prefix its Display carries.