Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter doi2cite #178

Merged
merged 9 commits into from
Jun 15, 2021
Merged

Add filter doi2cite #178

merged 9 commits into from
Jun 15, 2021

Conversation

korintje
Copy link
Contributor

@korintje korintje commented May 28, 2021

Add a filter doi2cite, which helps users to insert references into a document with using DOI(Digital Object Identifier) tags.

What the filter do

With this filter, users do not need to make bibtex file by themselves.
Instead, the filter automatically generate .bib file from the DOI tags (e.g. [@doi:xxxx.xxxx.xxx.]), and convert the DOI tags into citation keys available by pandoc --citeproc (e.g. [@Korintje_2021]).

Filter features

  • Get bibtex data of the DOI from http://api.crossref.org
  • Can be mixedly used with .bib files manually collected by users
  • Use saved bibtex data from the second time to avoid unnecessarily network accesses
  • Detect and avoid duplications of bibtex keys.

I'd be glad if I can get any comments or suggestions!

@korintje korintje force-pushed the master branch 2 times, most recently from 570b92d to cf2d0c5 Compare May 29, 2021 01:51
@tarleb
Copy link
Member

tarleb commented May 29, 2021

Thank you, this looks very useful! It's going to be about a week before I have time to review this in detail, but maybe one of the other maintainers can do so earlier.

@alerque
Copy link
Collaborator

alerque commented May 29, 2021

I'm not really qualified to review this; I'm not familiar with the assorted citation ecosystems or any of the issues surrounding them. It does look like you've done good work getting it setup, I'm just vaguely aware there are a lot of pitfalls/complexities in this area and don't have the eye to spot the or any test content to run it on.

@gnpan
Copy link

gnpan commented May 30, 2021

No problems so far. Also works well with author-date citation formats, respecting author suppression with [-@doi...] or citations without brackets to obtain Author et al. (2021) instead of (Author et al., 2021). If you want to use a second lua filter it's best to first create the expected.md and then convert that to pdf with citeproc etc.

Copy link
Member

@tarleb tarleb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is beautiful!

There are some very minor things like overlong (>80chars) lines in the README, as well as indentation, which uses 4 spaces instead of the default 2: it would be nice to be consistent, but I don't feel strongly about it.

The latest pandoc release caused some test failures unrelated to this filter. I'm working to fix those and will merge the PR afterwards.

korintje and others added 2 commits June 10, 2021 01:21
@korintje
Copy link
Contributor Author

korintje commented Jun 10, 2021

Thank you for the reviews and suggestions!

  • I fixed overlong lines in README (excepting long URL lines, because I'm just not sure how to wrap them.)
  • I changed indent spaces in doi2cite.lua from 4 to 2.

It would be smarter to substitute pandoc.path for split_path, but in my environment (pandoc 2.14.0.1 @ WSL Ubuntu 20.04), the field pandoc.path is nil, so I left it as it is for now.

@tarleb
Copy link
Member

tarleb commented Jun 10, 2021

Great, thanks!

but in my environment (pandoc 2.14.0.1 @ WSL Ubuntu 20.04), the field pandoc.path is nil,

Oh, that might be worth fixing in pandoc. You could still get it by using pandoc.path = require 'pandoc.path'.

@korintje
Copy link
Contributor Author

Fixed an error in the CI test.
I think the error occurred because test process tried to get a differences between two binary .pdf files.
I rewrote it to take the difference between "expected.md" and "output.md", mimicking examples of other filters.

@tarleb tarleb merged commit 5d2024b into pandoc:master Jun 15, 2021
@tarleb
Copy link
Member

tarleb commented Jun 15, 2021

Thanks again!

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.

4 participants