andras-simonyi / citeproc-el

A CSL 1.0.2 Citation Processor for Emacs.
GNU General Public License v3.0
85 stars 9 forks source link

Year-Month Date Feilds Cause Fatal Errors on Export #95

Closed yuki-tsubaki closed 2 years ago

yuki-tsubaki commented 2 years ago

I have been trying out citeproc-el along with Org's new citation system and it works great. lHowever, when I use a citation that has a date that only includes a year and month, it fails with an elisp error during the export.

The error is not always in the same function (it seems to vary with the specific format of date and desired csl stye), but is always a type error. Here are the ones I have seen so far:

citeproc-sort--date-var-key: Wrong type argument: number-or-marker-p, nil
citeproc-date--render-year: Wrong type argument: numberp, nil

I would assume this to be a problem only with general pre-export processing, but I checked with multiple styles and export formats to be more sure. It seems to happen regardless of export style (I checked in IEEE, MLA, APA, Vancouver, Nature, and some other styles) and export format (checked in html and LaTeX).

It happens when there is YYYY-mm date in the date feild, but is fine with a full YYYY-mm-dd or YYYY date feild of my biblatex file.

Here is a random sample entry you can use if you want that causes the problem.

@article{strathernImprovingRatingsAudit1997,
  title = {‘{{Improving}} Ratings’: Audit in the {{British University}} System},
  shorttitle = {‘{{Improving}} Ratings’},
  author = {Strathern, Marilyn},
  date = {1997-07},
  journaltitle = {European Review},
  volume = {5},
  number = {3},
  pages = {305--321},
  publisher = {{Cambridge University Press}},
  issn = {1474-0575, 1062-7987},
  doi = {10.1002/(SICI)1234-981X(199707)5:3<305::AID-EURO184>3.0.CO;2-4},
  url = {https://www.cambridge.org/core/journals/european-review/article/abs/improving-ratings-audit-in-the-british-university-system/FC2EE640C0C44E3DB87C29FB666E9AAB},
  urldate = {2021-10-07},
  abstract = {This paper gives an anthropological comment on what has been called the ‘audit explosion’, the proliferation of procedures for evaluating performance. In higher education the subject of audit (in this sense) is not so much the education of the students as the institutional provision for their education. British universities, as institutions, are increasingly subject to national scrutiny for teaching, research and administrative competence. In the wake of this scrutiny comes a new cultural apparatus of expectations and technologies. While the metaphor of financial auditing points to the important values of accountability, audit does more than monitor—it has a life of its own that jeopardizes the life it audits. The runaway character of assessment practices is analysed in terms of cultural practice. Higher education is intimately bound up with the origins of such practices, and is not just the latter day target of them. © 1997 by John Wiley \& Sons, Ltd.},
  langid = {english},
  file = {/home/pete/Zotero/storage/4NFWK44X/FC2EE640C0C44E3DB87C29FB666E9AAB.html}
}
andras-simonyi commented 2 years ago

Thanks for the report! Interestingly enough I couldn't reproduce the issue, the entry was rendered without any problems on my computer (in the default Chicago author-date style). Could you send a full MWE consisting of a short Org document and bibliography? Also, which Emacs, Org and citeproc-el versions are you using?

yuki-tsubaki commented 2 years ago

Sure, this happened on 538fed794c29acf81efee8a2674268bd3d7cc471 (the revision that the most recent release of Doom had it pinned at) and confirmed again using the current revision (as of like two hours ago).

GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2020-09-19 Org mode version 9.6 (9.6-??-0c9b30e @ /home/pete/.emacs.d/.local/straight/build-27.1/org/)

mwe.org

#+TITLE: Test
#+AUTHOR: testauthor
#+LANGUAGE: en
#+cite_export: csl
#+bibliography: bib.bib

This is a test [cite:@strathernImprovingRatingsAudit1997].

#+print_bibliography:

It still fails without the print bibliography keyword, but I thought I should still include it.

bib.bib


@article{strathernImprovingRatingsAudit1997,
  title = {‘{{Improving}} Ratings’: Audit in the {{British University}} System},
  shorttitle = {‘{{Improving}} Ratings’},
  author = {Strathern, Marilyn},
  date = {1997-07},
  journaltitle = {European Review},
  volume = {5},
  number = {3},
  pages = {305--321},
  publisher = {{Cambridge University Press}},
  issn = {1474-0575, 1062-7987},
  doi = {10.1002/(SICI)1234-981X(199707)5:3<305::AID-EURO184>3.0.CO;2-4},
  url = {https://www.cambridge.org/core/journals/european-review/article/abs/improving-ratings-audit-in-the-british-university-system/FC2EE640C0C44E3DB87C29FB666E9AAB},
  urldate = {2021-10-07},
  langid = {english},
}
andras-simonyi commented 2 years ago

Thanks, the Emacs version was crucial, I'm already on version 28, but using Emacs 27 I was able to reproduce the problem. Looks like there was a bug in Emacs's parse-time-string function with year-month dates which has recently been fixed. It seems I have to switch to a different way of parsing biblatex dates.

andras-simonyi commented 2 years ago

I've merged a PR (#97) which hopefully solves the problem.

yuki-tsubaki commented 2 years ago

Yep, that fixed it. Thanks again for the great program.