GeoBosh / Rdpack

R package Rdpack provides functions and macros facilitating writing and management of R documentation.
https://geobosh.github.io/Rdpack/
28 stars 6 forks source link

Support for biber? #15

Closed mjantti closed 3 years ago

mjantti commented 4 years ago

Many thanks for this hugely useful package. This is a question I fear may be annoying, given the amount of work you and others put into this tool and those it relies on, so apologies in advance. I have recently cleaned by bibliography databases and, in the process, converted them to biblatex/biber format. As a concsequence, Rdpack (or, as I suspect, bibtex) does not recognise some entry types. Recoding the databases is not big deal, but I am wondering all the same if adding support for biber would require substantial recodign/redesign? I suspect the answer is yes, but wanted to ask.

Best regards

Markus Jantti

GeoBosh commented 4 years ago

Thanks for the praise. Note that there is no need to be apologetic, requests for features, bug reports, critique, etc. are always welcome. They may or may not be followed up, of course.

Regarding support for biblatex/biber, can you post here examples of offending bib entries? Or even better, make a pull request at https://github.com/GeoBosh/reprexes (just add a bib file in the top directory of reprexes and create a pull request).

Full support is not feasible but, in general, if the entries are parsed by bibtex, then it is a matter of adding support for them in Rdpack. This depends mostly on demand/requests.

mjantti commented 4 years ago

Thanks. I uploaded (I think; git is quite new to me) an extremely simple example with three entries - the incompatibilities for those being have a "date" field rather than separate "year" and "month" fields, and "journaltitle" rather than "journal". Changing those (i.e., using "year" and "month" as well as "journal") instead fixed the issue.

Moving back to "pure" bibtex is not a big problem, so the fact my own database now is in biblatex/biber-format is not going to stop me from using Rdpack. But the ability to use biblatex-format entries would be useful.

GeoBosh commented 4 years ago

Thanks, I will have a look.

GeoBosh commented 4 years ago

After some thought, I have come to think that it is best, at least for now, to leave to the users the conversion of biblatex bib files to bibtex ones. There would be a substantial maintenance overhead and additional complexity if the citation macros were to do this on the fly.

Having said that, I don't rule out a cardinal solution in the future if a suitable off-the-shelf parser is available. Prompted by your question, I ported the excellent bibutils library to an R package, rbibutils. In the initial version it just converts from biblatex to bibtex, see examples for rbibutils::bibConvert() there if you don't have suitable routine for conversion.

For completeness, I will add that bibutils binaries are avaliable for linux distributions and a conversion from biblatex to bibtex can be done with something like

biblatex2xml mybiblatexfiile.bib | xml2bib > my.bib

The bibutils programs can also be compiled on most systems (including MSYS on Windows) by just following the instructions in its distribution, e.g. bibutils on CTAN.

mjantti commented 4 years ago

This sounds more than reasonable. The tips about bibutils are highly useful! I used to use bibtool a lot but moving to biblatex changed that a lot. I then used biber quite a bit rather than learning to use other tools, so this was very helpful. On the usage front, I simply re-coded by databases by hand. Nice tool, once again thanks for it, and thanks for making yet another R package!