quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.75k stars 306 forks source link

Communicate cell labels to Jupyter kernel. #10576

Open allefeld opened 3 weeks ago

allefeld commented 3 weeks ago

I suggested in #10541 that knitr's behavior, to replace code of the form <<label>> with the code from the referenced cell, for Jupyter kernels. @cscheid replied that this is unlikely to be implemented, and should better be implemented on the side of the kernel.

But for this to be possible, the kernel needs to be informed about the label (if any) of each sent code block.

cscheid commented 3 weeks ago

I don't think Jupyter's notebook execution model includes this information.

So we either:

Let's assume the latter for now. Jupyter does allow this through its comms: https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info

Quarto already uses this in notebook.py:

https://github.com/quarto-dev/quarto-cli/blob/04524462d5653b57969db2daa49a0b4dfc13bc19/src/resources/jupyter/notebook.py#L213-L219

We could implement this by sending additional per-cell messages in the quarto_comm channel (is that what they call this?).

allefeld commented 3 weeks ago

Sounds good!

But, this is something-that-would-be-neat-to-have-sometime, not important.