jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
221 stars 65 forks source link

Linking to a cell by cell ID #518

Open krassowski opened 1 year ago

krassowski commented 1 year ago

JupyterLab and nbconvert allow users to link to a specific cell by it's ID by using hash fragment like #cell-id=my-cell-id where my-cell-id is an example cell ID. JupyterBook nor MyST-NB does not support it yet (https://github.com/executablebooks/MyST-NB/issues/310) although a pull request is open (https://github.com/executablebooks/MyST-NB/pull/519).

Given that there is a new notebook parser in this repository, I wonder if it could facilitate implementation of such a feature.

Proposal

Adopt the same hash fragment scheme for HTML output as other projects.

Additional notes

It appears that support for a kind of cell IDs was implemented in https://github.com/executablebooks/mystmd/pull/361 but using a different scheme: nb-cell-0-code (and nb-cell-0-output for output). It appears that cell index was used there instead of cell ID which would not be a stable identifier when user moves cells around. For that I would propose using #cell-index=0 format where 0 represents first cell (whether 0- or 1-based). Also, please note that in Jupyter notebooks any single cell may have multiple outputs, so cell ID cannot identify output (but barely a list of outputs).

welcome[bot] commented 1 year ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

krassowski commented 10 months ago

@rowanc1 would you be open to a pull request?

krassowski commented 8 months ago

Just checking back here :eyes:

rowanc1 commented 4 months ago

Thanks @krassowski, always happy for a PR we can also look to your implementation in https://github.com/executablebooks/MyST-NB/pull/519. The IDs are also involved in how we identify and replace outputs in thebe, and our default htmlIds do not currently allow =. We should also likely check that the IDs provided by the ipynb are not duplicated.