jupyter-book / jupyterlab-myst

Use MyST Markdown directly in Jupyter Lab
https://jupyter-book.github.io/jupyterlab-myst/
BSD 3-Clause "New" or "Revised" License
146 stars 18 forks source link

jupyterlab-myst breaks navigating from the TOC outline #184

Closed parmentelat closed 11 months ago

parmentelat commented 1 year ago

Description

the outline TOC is no longer usable to navigate across the notebook once jupyterlab-myst is installed

to reproduce:

Proposed solution

I have not yet been able to investigate this issue, but am willing to, with a little guidance :)

Additional notes

initially posted in https://github.com/jupyterlab/jupyterlab/issues/14897 before I could pinpoint this to jupyterlab-myst

parmentelat commented 1 year ago

duplicated from the original issue, hopefully makes things clearer

navigation-toc-broken

rowanc1 commented 1 year ago

It looks like this has changed in JupyterLab 4 and this is no longer a simple anchor link as the notebook has become virtualized.

I think we need to add a new factory or something similar to this:

https://github.com/jupyterlab/jupyterlab/blob/1d989bad87e89307a336d2f671c9cc98ec37f5e9/packages/markdownviewer/src/toc.ts#L90

parmentelat commented 1 year ago

a little surprisingly, I have just noticed that the feature starts working again, apparently if I create an artificial delay in the notebook loading phase

more specifically:

in my limited understanding of the system, this could suggest some asynchronous function that is not properly awaited, or some similar flaw that would occur at load time

I'm still puzzled that the issue clearly relates to jupyterlab-myst though, since without this extension everything works fine...

parmentelat commented 1 year ago

let me add that I am much impeded by this issue, and that am quite willing to spend more time investigating it

as part of my attempts I have tried to follow-up on @rowanc1's idea to register my own brew of a MarkdownViewerTableOfContentsFactory in the tocRegistry, but could not go very far down this road, mostly because I could not figure out

  1. which registered factory is supposed to trigger in what context
  2. nor how exactly to customize such a factory - short of redefining _createNew which looked like too big a chump to swallow so I gave up when I realized the above
parmentelat commented 1 year ago

finally I'd like to report that the issue happens also in the "Markdown Preview" and the "Editor" document views, and in both cases apparently adding an artificial delay as explained above makes the feature working again

parmentelat commented 1 year ago

looks like this might very well be an issue on jupyterlab proper after all, and that it is being addressed here

https://github.com/jupyterlab/jupyterlab/pull/14884

parmentelat commented 1 year ago

to be more explicit, the referenced PR does fix the issue that I have when using the TOC with the jupyterlab-myst extension loaded clearly a workaround because there obviously are deeper issues in the jlab loading phase that create the conditions for the issue regardless, this is currently a major productivity impediment, at least as far as I am concerned, so if the PR makes it to being merged, whether it's a clean fix or not, it would be a great relief already...

parmentelat commented 11 months ago

quite obviously, as per both https://github.com/jupyterlab/jupyterlab/issues/14897 and https://github.com/jupyterlab/jupyterlab/issues/14591 the issue is totally a jupyterlab one after all

am closing this one

rowanc1 commented 11 months ago

Thanks for following up @parmentelat!