-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Unique IDs for headers (avoid duplicates) #1932
Comments
Forgot to tag people I've talked about this with @blink1073 @Carreau @ian-r-rose @takluyver. |
You forget external links to a particular section IIUC, like a number of repos have (for example in their README) My take on this is:
The second one might be tackled lated, and will also help when section get renamed/merge. |
This illustrates what I mean about UUIDs: The user could write |
(updated the comment above). |
@Carreau That use case was what I meant by cross notebook linking. If you weren't linking to a particular section (or more generally a particular id) then the anchors themselves wouldn't come into play. @blink1073 Is the idea to have people write their links using Looking at the href of the If we're going to go this route for UUIDs, we should probably surface a better way to handle within document links (let alone between document links). How hard would it be to extend codemirror to allow us to inject tab completion on seeing a If we could get that to work we could probably do more and also do tab completion for I'm not sure if this should be a new issue, but @ian-r-rose and I were working on this (e.g., #1945), which led us to realise that this is a problem not just for the notebook but for markdown in general. This is because we're using the same rendermime to handle all instances of markdown regardless of the file format they're in. I kinda like that idea, but it almost certainly will mean that we're going to run into issues with people's expectations around ids, linking &c. & how other services render markdown. For example, Is there a downside to including phantom anchors to hold ids on behalf of different formats manner for auto-generating header ids? Because if there really isn't, then I think I have a thought about how to handle this particular problem. UUIDs don't solve the multiple ids in the same notebook issue, I think the best chance of that might be to prioritise making manual ids possible (exclusively via the |
@mpacer, the way we are handling this for links to documents in JLab is to use the command linker, which adds a data attribute to the anchor that, when clicked, runs a command in JLab to open the path rather than the default action of the click. This could be extended to include the hash, so that the href of the anchor would not have a uuid but the action of clicking it would have the path encoded. cf jupyterlab/packages/rendermime/src/widgets.ts Line 478 in 53a60f7
|
From #12402: Headers should contain ASCII characters only for maximum compatibility. |
This is a followup to the discussion began in #1736 around using UUIDs as part of the automatic id generation scheme for headers.
Basic problem layout: right now, if you have a notebook and you have
in the same notebook, both headers will have the same id (specifically
#my-header
). Aside from violating html standards for id uniqueness, this makes it impossible to link to the second instance of the header even though it assigned an anchor link.This problem is dramatically worse for jupyterlab due to the possibility of multiple notebooks being in the same window at the same time (not only because it is more likely that header text is shared between notebooks(in general), but because of the combinatorial growth of opportunities to conflict that arise with each additional notebook injecting ids into the namespace).
One proposed solution to this problem is to instead build ids that contain UUIDs for identifying (at least) the notebook from the id originates.
The main problem I see with this approach is that this eliminates the ease of use for writing links to different parts of the document. Not only does no one want to have to type
[link to header](#link-to-header-<header_uuid>)
in order to link, what's worse is that there's no way to write the link without rendering the cell and looking at the actual anchor that was generated.But there are conceptual issues as well: for example, if you ever copy and paste a cell with a UUID already being present — do you create a new one and therefore break any links that also are copied and pasted?
There are a lot of issues embedded in these topics but I've tried to distill them to specific use cases for ids and where challenges might arise:
E.g., Header has id 1 , changing the text of an header, render (generates a new id 2), breaks links pointing to id 1 , changing the header text back to original, render (generates a new id 3), does 1==3?
The text was updated successfully, but these errors were encountered: