pandoc / lua-filters

A collection of lua filters for pandoc
MIT License
611 stars 166 forks source link

Add filter doi2cite #178

Closed korintje closed 3 years ago

korintje commented 3 years ago

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

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

tarleb commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.

korintje commented 3 years ago

Thank you for the reviews and suggestions!

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Thanks again!