Skip to content

Parse biblatex fields date, journaltitle and location in bibtex readers - #11

Open
ms609 wants to merge 3 commits into
GeoBosh:masterfrom
ms609:biblatex-date-journaltitle
Open

ms609 wants to merge 3 commits into
GeoBosh:masterfrom
ms609:biblatex-date-journaltitle

Conversation

@ms609

@ms609 ms609 commented Sep 16, 2026

Copy link
Copy Markdown

I use Zotero with Better BibTeX to manage citations. Exported bib entries (and biblatex files in general) use date and journaltitle where BibTeX has year/month/day and journal, e.g.

@article{smith2020,
  author = {Smith, John},
  title = {A title},
  journaltitle = {Some Journal},
  date = {2020-02-02}
}

utils::bibentry() rejects such an Article (no journal, no year), so readBib() drops the entry with a warning under both direct = TRUE and direct = FALSE. Downstream, Rdpack's \insertCite then cannot cite it.

I've been manually replacing journaltitle with journal, and truncating date to year (and often forgetting to to this!). But as the same .bib works in R Markdown/Quarto vignettes (pandoc understands these fields), I wondered whether it might be possible for these fields to be supported here also.

I set Claude onto the task; this PR is the result. I've tested the code locally and it succeeds.


Change

process_ref() in src/common_bt_btd.c (shared by the bibtexin and bibtexdirectin readers) now normalises these biblatex fields, following pandoc's citeproc BibTeX reader (and biber):

  • date: if it has the form [-]YYYY[-MM[-DD]], optionally followed by EDTF qualifiers (~ ? %), a time (T…) or a range (/…), it sets year, month (full month name, as for month = feb) and day, taking precedence over any year/month/day fields. An unparsable date (e.g. circa 2004) is ignored and year is used. For a range, only the start is used, since bibentry has no range.
  • journaltitle takes precedence over journal.
  • location supplies address if that is missing, except for @patent, where biblatex's location is the jurisdiction.

The biblatex fields themselves are kept (visible with direct = TRUE).

Checks

  • New test and fixture inst/bib/biblatex_aliases.bib, run with both direct = TRUE and FALSE; it fails without the patch.
  • Full test suite passes before and after.
  • Compared readBib() output for every file in inst/bib/ before and after, with both values of direct: the only file whose output changes is biblatex-examples_sans_key_aksin.bib, which now returns 84 rather than 32 entries (direct = TRUE) and 70 rather than 17 (direct = FALSE). Nothing previously read changes except for added year/journal/address fields.
  • Output for the test file agrees with pandoc --citeproc on year, month, journal and place.
  • Compiles without warnings with -Wall -pedantic.
  • Rdpack's test suite passes against the patched package.

Documented in ?readBib (Details) and NEWS.md.

🤖 Generated with Claude Code

ms609-agent and others added 3 commits September 16, 2026 09:33
…readers

Biblatex files (e.g. Zotero's Better BibTeX exports) use 'date' and
'journaltitle' where bibtex has 'year'/'month'/'day' and 'journal'.
bibentry() then refuses Article etc. entries, so readBib() dropped them
with a warning, both with direct = TRUE and direct = FALSE.

process_ref(), shared by both bibtex readers, now maps these fields,
mirroring pandoc's (and biber's) handling:
- a parsable 'date' ([-]YYYY[-MM[-DD]], optionally with range, time or
  EDTF qualifiers) sets year/month/day, overriding the bibtex fields;
- 'journaltitle' overrides 'journal';
- 'location' supplies 'address' if missing (not for patents, where it
  is the jurisdiction).
The biblatex fields are kept.

Recovers 52 previously dropped entries of inst/bib/biblatex-examples;
no other bundled bib file changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ms609
ms609 marked this pull request as ready for review September 16, 2026 10:02
@GeoBosh

GeoBosh commented Sep 18, 2026

Copy link
Copy Markdown
Owner

Many thanks.

I am still travelling but will deal with this at the beginning of October.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants