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

Does not work when used with normal citekey #10

Open
chrisgrieser opened this issue Aug 15, 2021 · 4 comments
Open

Does not work when used with normal citekey #10

chrisgrieser opened this issue Aug 15, 2021 · 4 comments

Comments

@chrisgrieser
Copy link

chrisgrieser commented Aug 15, 2021

Thank you for this useful filter.

The filter works wonderfully, except when I have [@citekeys] in my input file, that originates from my bibtex library. When trying to use an "url2cite-citation" and a normal Pandoc citation together, the whole Pandoc conversion fails with the following error:

extraction error Error: Could not find URL for @GlaeserLaudel2005.    at Object.astTransformer [as single] (/usr/local/lib/node_modules/pandoc-url2cite/dist/index.js:161:31)    at walk (/usr/local/lib/node_modules/pandoc-url2cite/node_modules/pandoc-filter/index.js:60:41)    at async walk (/usr/local/lib/node_modules/pandoc-url2cite/node_modules/pandoc-filter/index.js:79:22)    at async walk (/usr/local/lib/node_modules/pandoc-url2cite/node_modules/pandoc-filter/index.js:67:32)    at async walk (/usr/local/lib/node_modules/pandoc-url2cite/node_modules/pandoc-filter/index.js:79:22)    at async filter (/usr/local/lib/node_modules/pandoc-url2cite/node_modules/pandoc-filter/index.js:177:13)    at async Url2Cite.transform (/usr/local/lib/node_modules/pandoc-url2cite/dist/index.js:232:16)    at async go (/usr/local/lib/node_modules/pandoc-url2cite/dist/pandoc-url2cite.js:22:12)Error running filter pandoc-url2cite:Filter returned error status 1

this is the markdown file I am running it on

# Introduction

The GAN was first introduced in [@gan].

Cras lacus justo, rhoncus in porta sed, dapibus eu tortor[@GlaeserLaudel2005].

# References

[@gan]: https://papers.nips.cc/paper/5423-generative-adversarial-nets

The Bibliography file contains an entry with the citekey "@GlaeserLaudel2005" and the citkey is converted properly when leaving out url2cite as filter.

for reference, here is my pandoc command.

pandoc '/Users/chrisgrieser/Google Drive/File Hub/test.md' -o '/Users/chrisgrieser/Google Drive/File Hub/test 15-08-2021.docx' --filter='pandoc-url2cite' --citeproc --resource-path='/Users/chrisgrieser/Google Drive/File Hub/' --resource-path='/Users/chrisgrieser/Google Drive/File Hub/attachments/' --bibliography '/Users/chrisgrieser/Google Drive/BibDesk/My Library.bib' --csl '/Users/chrisgrieser/Google Drive/Dokumente/IT Backups/Alfred.alfredpreferences/workflows/user.workflow.41B90DCD-A99E-4943-A19A-E91859557FB0/citation-styles/research-policy.csl' --number-sections --from=markdown+lists_without_preceding_blankline --metadata link-citations=true --metadata date="$(date "+%e. %B %Y")" --reference-doc '/Users/chrisgrieser/Google Drive/Academia/Vorlagen/Academic Writing Template.docx'
pandoc 2.14.1
Compiled with pandoc-types 1.22, texmath 0.12.3, skylighting 0.11,
citeproc 0.4.1, ipynb 0.1.0.1

Or did I misunderstand something and the filter is not intended to be used in combination with normal citekeys? because that would be all to be bad, I'd love to use this filter, but there are too many references without DOIs in my discipline that I can solely rely on it.

@phiresky
Copy link
Owner

phiresky commented Aug 15, 2021

Or did I misunderstand something and the filter is not intended to be used in combination with normal citekeys?

Right now there's four ways you can use url2cite in combination with "manual" citations:

  1. Prefix the cite key with raw:. e.g. [@raw:foobar]. These are ignored by url2cite. This was broken, i just published 0.6.14 that fixes it.
  2. set url2cite-allow-dangling-citations=true. That suppresses the Could not find URL for @foobar. error and makes url2cite just ignore any cite keys that aren't aliased to an url.
  3. Use an URL as a cite-key. Doesn't need to have a DOI, just any website that's relevant to the work is fine as long as zotero understands it. Then manually adjust the CSL entry url2cite generates in citation-cache.json.
  4. Use an URL as a cite-key like in (3), but directly add the bibtex in a code block with language url2cite-bibtex anywhere:
    see also @{https://github.com/DLR-RM/stable-baselines3}.
    
    ```url2cite-bibtex
    @misc{https://github.com/DLR-RM/stable-baselines3,
    author = {Raffin, Antonin and Hill, Ashley and Ernestus, Maximilian and Gleave, Adam and Kanervisto, Anssi and Dormann, Noah},
    title = {Stable Baselines3},
    year = {2019},
    publisher = {GitHub},
    journal = {GitHub repository},
    howpublished = {\url{https://github.com/DLR-RM/stable-baselines3}},
    }
    ```

Does one of those methods work for you?

pandoc-url2cite currently completely ignores the bibliography info passed as e.g. --bibliography in pandoc since I think the content of that bibliography is not actually included in the JSON AST so I would have to parse it myself.

@chrisgrieser
Copy link
Author

chrisgrieser commented Aug 15, 2021

Thanks for the swift response!

Well, my discipline is sociology and we regularly cite classic work, often 60 years or older. So no URLs there... 😢

With a higher number of manual references, this practically only leaves option 2), which works totally fine, I just tested it. I would actually suggest to maybe make url2cite-allow-dangling-citations=true the default option as I imagine that many people like me will have to / want to use url2cite only for some references and not exclusively. (I mean, even using url2cite for some references is already a huge time saver!)


On a slightly different note, is there some further documentation of url2cite I am note aware of? I could not find any reference to the url2cite-allow-dangling-citations option in the readme, and url2cite --help in the Terminal also does not work?

@phiresky
Copy link
Owner

I would actually suggest to maybe make url2cite-allow-dangling-citations=true the default option

That might be true.. though this would make it harder to spot errors for the "ideal" case, and in many cases I think the other methods might be better. I've added the information on how to fix it (prefix with raw: or set that config option) to the error that is thrown so it should be easy to find from now on.

is there some further documentation of url2cite I am note aware of

There wasn't, really. I've added the information I wrote above plus some more to the readme. :)

@chrisgrieser
Copy link
Author

That might be true.. though this would make it harder to spot errors for the "ideal" case, and in many cases I think the other methods might be better.

Might be, but in many disciplines, using solely url2cite is unfortunately not an option. That you aren't getting this request more often probably only stems from the fact that not many non-computer-science people use it yet. (Which is a shame, considering how useful this is.)

Well anyway, thanks for the quick info!

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

No branches or pull requests

2 participants