Conversation
enables direct links to anchors within notebooks
|
Does it behaves correctly when text have space/special char ? Do you think we should reduce the used caracter for the anchor to |
|
Yes, it behaves just fine with spaces, etc. |
|
I should note that this plus #3058 mean you can have links to particular anchors inside other notebooks, with syntax like: |
|
wouldn't the redirect remove the hashtag ? |
|
And the notebook regex |
No and no. The hash is not actually part of the URL - it is part of the request, much like url parameters after I have tested locally with both PRs merged, and confirmed that it works as expected. |
|
This one with #3058 is really, really great! I hope to see both merged soon ;-) |
|
One question? Wouldn't be beneficial to have anchors not only to heading cells, but also to any other cell in the notebook? It would be relevant when you have a lot of code in multiple cells an you want to point out to a specific code cell (and do not want to add a heading just for tagging)... |
|
Yes, I think that will make sense. It wasn't obvious to me what those tags should be, so I left it for another time. One option would be to use the cell ID metadata, but I'm not convinced yet. |
instead of the other way around. This way, only clicking the text loads the hash link, rather than the whole area.
|
I was also thinking in the cell metadata... This is an infrastructure available right now and we can use it to get anchors to each cell. |
|
IMHO, cell id is delicate, it should be baked into the notebook format seeing the number of things that could rely on it. Otherwise I'm ok with the hash. +1 for merging. |
There was a problem hiding this comment.
was the pseudo selector :link intended ? Or did you ment to apply the style to even the non-visited link ?
There was a problem hiding this comment.
I believe this code is exactly what I meant it to be, but I'm still shaky on CSS. It prevents adding link-styling to the heading text.
There was a problem hiding this comment.
it seem to me that link is only a subcategory on link. Deployed on nbviewer it does not remove the styling...but it might be a combine effect with the fact that the anchor tag do not have href attributes.
There was a problem hiding this comment.
This definitely does the right thing on the live notebook, so nbconvert must not be generating the same HTML.
There was a problem hiding this comment.
For me, once the link/header are clicked once, they appear blue.
There was a problem hiding this comment.
The only way I found to have it correctly on live notebook is to set both :link and :visited one with color:inherit the other without.
There was a problem hiding this comment.
My custom CSS got in the way, PR #3143 should fix. Thanks for the vigilance!
There was a problem hiding this comment.
Both should have color:inherit - the heading text should never be colored.
|
When i link to a heading within a single notebook, an entirely new notebook session is opened (in a new tab). |
|
In what context are you creating these links? |
|
in a markdown cell i have |
|
makes sense. Try PR #3824. |
|
In a comment above it is said that these links work for notebooks that have spaces in their names. This does not appear to work for me. in a markdown cell i have: once executed, the result is not highlighted. i have also noticed that linking to local headings (#3824) that contain spaces requires the spaces to be replaced with hyphens |
|
Yes - I was wrong above, and the hyphen fix was made in a later PR (I don't recall which). |
|
ok thanks. So, to be clear:
|
|
Both internal and external links work by substituting hyphen for space. The id of the div has only one value, so they mustn't be different. The following links: [external](A.ipynb#has-space)
[internal](#has-space)both work for linking to a heading cell with the text "has space" (just tested and confirmed with master). |
|
yes, what i was trying to describe was a link to a notebook, which had spaces in its name.
|
|
Ah, gotcha. Yes, there is a difference between a URL path and an anchor ID. It looks like there is a bug in the markdown parser for URLs. If you put |
|
works. thanks . |
|
Hi, thanks for this feature, but here's a use case that isn't currently supported. If I have headers like this:
i.e. some headers are duplicated under different parents, the anchors of all "copies" point to the first one. Do you think this use case is worth supporting or should I just work around it? I think it would be convenient to have such a feature. It could be implemented by prefixing anchors with all higher level headers' anchors. |
add anchors to heading cells
following ipython/ipython#3064
and trigger standard anchor scrolling on notebook load. It doesn't work regular on page load because the elements don't exist yet.