krassowski / jupyterlab-citation-manager

Citation Manager for JupyterLab using Zotero Web API
BSD 3-Clause "New" or "Revised" License
63 stars 2 forks source link

Allow to embed citations using Jupyter Book syntax #15

Open krassowski opened 3 years ago

krassowski commented 3 years ago

https://jupyterbook.org/content/citations.html

krassowski commented 3 years ago

Additional discussion on gitter: https://gitter.im/jupyterlab/jupyterlab?at=61057eae6ccf813819e9f6a3

baggiponte commented 2 years ago

Hi, adding one footnote to this issue.

As one should expect, with Jupyter Books if I store my bibliography in a .bib file but insert the citations with the citation-manager, these won't be inserted because Jupyter Book does not recognize the format.

The converse, however, is also true: if I insert the bibliography with the citation-manager at the end of a chapter with alt - B and then build the book, no references will be added. Perhaps this is because the <div class="csl-entry"> ... </div> tags cannot be parsed?

Also, how do you see this being implemented? I would love to help out on this one, because of the crazy synergy. Could the citation manager retrieve citations from a .bib file? Is this just a matter of citation keys not matching? Could the metadata in the ipynb notebook be rewritten in a format that could be used in the md:myst notebook to build a book?

baggiponte commented 2 years ago

The converse, however, is also true: if I insert the bibliography with the citation-manager at the end of a chapter with alt - B and then build the book, no references will be added. Perhaps this is because the

...
tags cannot be parsed?

I can confirm removing the <div>...</div> tags solves the issue. To be fair, I removed all <div>, <i> and comment <!--...--!> tags (the italic was not parsed). A script that removes these should be easily implemented, even simply using sed. Then, to have the reference list at the end of the book I simply cut-pasted these into a references.md file that I added as the last chapter, here.

I believe the better place to put this should be closer to jupytext, shouldn't it? This is easier said than done, I guess... But as far as to make sure that people using jupytext/jupyter book and the citation-manager, this seems a viable short-term solution.

The real deal of this thing should be to have the citation-manager use the same reference keys that appear in the .bib file, so that the bibliography is automatically generated like this. Then, it should just be a matter of replacing the html tags with the MyST syntax.

krassowski commented 2 years ago

counterpoint: if the div tag is a problem, shouldn't it be fixed in nbconvert/jupyter book?

baggiponte commented 2 years ago

that makes a lot of sense xD I am new to these things, would you ping some maintainer of jupyterbook or shall I open the issue there?