retorquere / zotero-better-bibtex

Make Zotero effective for us LaTeX holdouts
https://retorque.re/zotero-better-bibtex/
MIT License
5.21k stars 285 forks source link

Feature request: Quick Copy / Citation picker support for nbconvert/Jupyter #2681

Closed saf-dmitry closed 10 months ago

saf-dmitry commented 11 months ago

Debug log ID

NA

What happened?

Please add Quick Copy/drag-and-drop and citation picker support for syntax compatible with the nbconvert tool for converting and exporting Jupyter Notebooks. Here is an example of what you would type into a Markdown cell:

<cite data-cite="granger2013">(Granger, 2013)</cite>

Here, grander2013 should be the citation key generated by BBT. As far as I understand, one citation can contain only one item.

github-actions[bot] commented 11 months ago

Hello there @saf-dmitry,

Hope you're doing well! @retorquere is here to help you get the most out of your experience with Better BibTeX. To make sure he can assist you effectively, he kindly asks for your cooperation in providing a debug log – it's like giving him the key to understanding and solving the puzzle!

Getting your debug log is a breeze and will save us both time. Trust me, it's way quicker than discussing why it's important. :smiley:

How to Share Your Debug Log:

  1. If the issue involves specific references, citekey generation, or exports, just right-click on the relevant item(s) and choose "Better BibTeX -> Submit Better BibTeX debug log" from the menu.

  2. For other issues, follow these simple steps:

    • Restart Zotero with debugging enabled (Help -> Debug Output Logging -> Restart with logging enabled).
    • Reproduce the problem.
    • Select "Send Better BibTeX debug report..." from the help menu.

Once you hit that submit button, you'll get a special red debug ID. Just share that with @retorquere in this issue thread. If the question is regarding an export, don't forget to include what you see exported and what you expected.

By sharing your debug log, you're giving @retorquere a clearer picture of your setup and the items causing the issue. It's like a superhero cape for him – he can swoop in and tackle the problem much faster.

We totally get that your time is valuable, and we appreciate your effort in helping @retorquere help you. You might be surprised at how much this simple step speeds up the whole process.

Thanks a bunch!

PS: If the Debug Log menu does not appear, or it does not send the debug log

A fallback option is available under "Help" > "Send debug log to file.io".

saf-dmitry commented 11 months ago

I cannot send a debug log, because it appears to be empty. Besides, Zotero complains to be out of memory (not sure if this prevents me from sending a log). I turned BBT caching off, but the issue remains.

Screen Shot 2023-10-18 at 14 51 17

Strange enough, I am on macOS, not Windows.

retorquere commented 11 months ago

Is this Zotero 6 or 7 beta?

github-actions[bot] commented 11 months ago

:robot: this is your friendly neighborhood build bot announcing test build 6.7.129.2681.5246 ("wrong check for out of memory")

Install in Zotero by downloading test build 6.7.129.2681.5246, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

saf-dmitry commented 11 months ago

Is this Zotero 6 or 7 beta?

Zotero 6.0.28

saf-dmitry commented 11 months ago

I've just installed the build 6.7.130. The "out of memory" error message is gone. I submitted a debug log.

Debug log ID: GZCFLH7T-euc/6.7.130-6

retorquere commented 11 months ago

Allright. Can you test the jupyter quick copy?

saf-dmitry commented 11 months ago

I briefly tested the new Jupyter notebook Quick-Copy format. It appears to work just fine. Thank you for your prompt help!

Looking forward to see the format support in citation picker a.k.a. Cite as you write (CAYW)!

By the way, I'm wondering why the formats supported by Quick-Copy and CAYW are different. For example, CAYW supports MultiMarkdown (MMD) citations, while Quick-Copy doesn't.

retorquere commented 11 months ago

No particular reason, they don't share much qua implementation. What other features does jupyter citation support (stuff like page number etc)?

retorquere commented 11 months ago

This format isn't really a standard for jupyter it seems - quarto and jupyterbook have a different syntax. Where is this format documented?

saf-dmitry commented 11 months ago

This format isn't really a standard for jupyter it seems - quarto and jupyterbook have a different syntax. Where is this format documented?

Unfortunately, there is no "official" format for citations in Jupyter notebooks (as far as I know).

Nbconvert is one of the most adopted tools for converting Jupyter notebooks into another static format including HTML, LaTeX, PDF, Markdown, reStructuredText, and more. The citation format is documented in the official nbconvert documentation.

Quarto and pandoc use pandoc citation format. Jupyter Book uses MyST Markdown flavour and requires installing an extension for JupyterLab to render MyST in Markdown cells.

There are also extensions for managing citations from Zotero in Jupyter notebooks: cite2c for Jupyter Notebook and jupyterlab-citation-manager for JupyterLab. Both extensions use formats that are similar to nbconvert citation format, but the user's reference database is accessed online using the API key (no support for local Zotero installation 😞).

The is also the Calico Document Tools, but the project is apparently dead by now. A description can be found here.

What other features does jupyter citation support (stuff like page number etc)?

As far as I know, you can put basically anything between the opening and closing cite tags. This part is only rendered in Jupyter notebook, but is completely replaced by nbconvert according to the citation style used. I.e., only citation key matters, everything else, like page numbers, will be ignored by the conversion process.

retorquere commented 11 months ago

As far as I know, you can put basically anything between the opening and closing cite tags. This part is only rendered in Jupyter notebook, but is completely replaced by nbconvert according to the citation style used.

Is there any documentation on this format? It's pretty anemic if it doesn't support locator rendering.

saf-dmitry commented 11 months ago

Is there any documentation on this format? It's pretty anemic if it doesn't support locator rendering.

The citation format is documented in the official nbconvert documentation.

Citations are handled by the citation2latex filter as part of the nbconvert tool. Looking in the source code of the default filter will tell you the "ultimate truth" how citations are handled. Like stated in the documentation, you can use basically any HTML tag with a data-cite attribute. The output LaTeX \cite{...} command is hardcoded, i.e., there is no place to accommodate locators. To implement locator handling like e.g., \cite[<locator>](<citation_key>) you could modify the citation filter accordingly.

There is also an open issue related to citation format in the nbconvert repository.

github-actions[bot] commented 10 months ago

:robot: this is your friendly neighborhood build bot announcing test build 6.7.136.2676.5340 ("fixes #2681")

Install in Zotero by downloading test build 6.7.136.2676.5340, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

retorquere commented 10 months ago

I'll need you to test this before I integrate this into a release.

saf-dmitry commented 10 months ago

The provided link to test build 6.7.136.2676.5340 is broken.

What exactly should I test? Quick Copy functionality? CAYW citation picker (what URI format)?

retorquere commented 10 months ago

Builds expire. I'll get you a new build later. It has both CAYW and quick copy, format is jupyter.

github-actions[bot] commented 10 months ago

:robot: this is your friendly neighborhood build bot announcing test build 6.7.137.2681.5385 ("new DB schema")

Install in Zotero by downloading test build 6.7.137.2681.5385, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

saf-dmitry commented 10 months ago

Quick Copy works as expected, but CAYW can't find the required format:

Screen Shot 2023-11-24 at 16 41 29

Debug Log ID: G4R6E59S-euc/6.7.137.2681.5385-6

github-actions[bot] commented 10 months ago

:robot: this is your friendly neighborhood build bot announcing test build 6.7.137.2681.5388 ("cayw formatter")

Install in Zotero by downloading test build 6.7.137.2681.5388, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

saf-dmitry commented 10 months ago

Now both, Quick Copy and CAYW citation picker, work as expected 👍.

saf-dmitry commented 10 months ago

Please, don't forget to add the new CAYW format to the documentation page.

retorquere commented 10 months ago

I'll add them, there's currently a problem with updating the site, so I don't know how long it'll take.

retorquere commented 9 months ago

they have been added