-
Notifications
You must be signed in to change notification settings - Fork 807
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
[toc2] with github html preview #1023
Comments
Hmm, it seems like all the sidebar links (which are generated by javascript, and only specify a hash, like Essentially, I think this could be considered a fault of htmlpreview.github.io, rather than toc2. |
Thanks very much for the detailed reply! Is it possible to modify the javascript to generate a full uri? (I can try to make this change on my own if it's not too complicated) I've seen a working sidebar in ahambi/140824-TOC here and just want to try in case the href handling from htmlpreview was intended. |
yes, I agree with @jcb91's analysis. the bug is more on the htmppreview side. a.attr("href", window.location.href + '#' + h.attr('id')); and see if it works? |
Ah, the working example is interesting. I think the difference is that in ahambi/140824-TOC's code (adapted from minrk's), the links are generated by cloning the href of the link in the original header: h = element.find("div.text_cell_render").find(':header').first();
var a = h.find('a').clone();
new_a.attr("href", a.attr("href")); and since the header anchor links have already been processed by htmlprevew, the adjusted URI is used for the toc link too. Although really they should be looking for In contrast, the toc2 from this repo generates its links directly using ids, so it doesn't get the modified versions, leading to the behaviour you describe. I think @jfbercher's solution explicitly adding the window href should work fine. Alternatively, another possible fix would be to adopt the previous method, and modify line 26 to read a.attr("href", h.find('.anchor-link').attr('href')); |
Thanks @jcb91 . |
Thank you very much @jcb91 and @jfbercher ! It seems now the side bar link points only to the prepended part not the full uri (e.g. And as @jfbercher said, I wasn't able to implement local changes made to toc2.js (I did the editable install but the change in local file does not take effect for some reason?) |
I think "cloning the href of the link in the original header" as mentioned by @jcb91 is more robust. The query string after https://htmlpreview.github.io/? won't be preserved by current method: a.attr("href", window.location.origin + window.location.pathname + '#' + h.attr('id')); |
@mhsekhavat Sure! For the cloning version, I am not sure that Anyway there are many changes coming and I think that this question should be reconsidered thenafter. |
@bianbian2010 |
Seems to be solved by #1031. Closing. Reopen if I missed something. |
Hi~
It seems the section links in the floating/side table do not work in html preview mode example here (links in the static table do work so I think it might be how the section IDs are appended to the link?)
I am very new to Jupyter and html/css so sorry for my ignorance. Please let me know if there is a quick fix I can apply on my own to resolve this issue.
Thanks very much!
The text was updated successfully, but these errors were encountered: