Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header links working in Jupyter Notebook/Lab but no longer on a built site #473

Open
maximlt opened this issue Feb 15, 2023 · 0 comments
Open

Comments

@maximlt
Copy link

maximlt commented Feb 15, 2023

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 [https://github.com/orgs/executablebooks/discussions/930] 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant