Skip to content

Instantly share code, notes, and snippets.

@mxpiotrowski
Created April 20, 2024 19:16
Show Gist options
  • Save mxpiotrowski/0e7d26980db8554b62ca61a476adc958 to your computer and use it in GitHub Desktop.
Save mxpiotrowski/0e7d26980db8554b62ca61a476adc958 to your computer and use it in GitHub Desktop.
-- Time-stamp: <2024-04-20T21:07:41+0200 mpiotrow>
--[[ When converting from biblatex to bibtex, Pandoc only considers
URL fields: DOIs get lost in the conversion (see
<https://github.com/jgm/pandoc/blob/main/src/Text/Pandoc/Citeproc/BibTeX.hs>).
This filter copies the values of DOI fields to URL fields, so that
they are output to bibtex. ]]
function Pandoc(d)
refs = pandoc.utils.references(d)
local i, entry = next(refs, nil)
while i do
if refs[i].DOI then
refs[i].URL = "https://doi.org/" .. refs[i].DOI
end
i, entry = next(refs, i) -- get next index
end
d.meta.references = refs
return d
end
@drupol
Copy link

drupol commented May 4, 2024

Shouldn't this be fixed in Pandoc directly instead?

@mxpiotrowski
Copy link
Author

I agree, but I needed a solution now ;-) The change would be trivial, but I’m not building Pandoc from source, so I can’t make a PR, just add another enhancement request to the 1000+ issues…

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