Header links working in Jupyter Notebook/Lab but no longer on a built site
TL;TR
We've found that links to headers that work when working from within Jupyter Notebook/Lab no longer work when on a page built from the same notebook with MyST-NB.
(I originally opened a discussion but this honestly feels more like a bug in MyST-NB, happy to be proven wrong :)!)
Details
So let's say you have this bit of Markdown in a notebook. Note that the link is #My-Title, it's cased as the header it's pointing too. This works, from your open notebook you can click on the link and gets redirected to the linked header.
[A description](#My-Title)
# My Title
However, the link as defined above does not work when that notebook is built with MyST-NB and turned into HTML. Apparently MyST-Parser auto-generates header anchors and the docs say:
The anchor “slugs” created aim to follow the GitHub implementation:
- lower-case text
- remove punctuation
- replace spaces with -
- enforce uniqueness via suffix enumeration -1
So in the simple case above, the difference seems to be in how the slug is cased. If the link would be written as [A description](#my-title), so all lower-cased, then that link would work on the website. But it would no longer work in Jupyter Notebook/Lab 🙃
Is there any way we could write these links so that they work in both context?
MyST-Parser docs suggest that to change the slug generation function, set myst_heading_slug_func in your conf.py to a function that accepts a string and returns a string.
Shouldn't MyST-NB specialize this function so that it respects the Jupyter spec for these links?
Running into the same issue...