Skip to content

Commit

Permalink
[toc2] Add full href (again) in links, cf #1023
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbercher committed Aug 12, 2017
1 parent 6d83cb9 commit e43e7a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function removeMathJaxPreview(elt) {

var make_link = function(h, num_lbl) {
var a = $("<a/>");
a.attr("href", '#' + h.attr('id'));
a.attr("href", window.location.href.split('#')[0] + '#' + h.attr('id'));
// get the text *excluding* the link text, whatever it may be
var hclone = h.clone();
hclone = removeMathJaxPreview(hclone);
Expand All @@ -60,7 +60,7 @@ var make_link = function(h, num_lbl) {

var make_link_originalid = function(h, num_lbl) {
var a = $("<a/>");
a.attr("href", '#' + h.attr('saveid'));
a.attr("href", window.location.href.split('#')[0] + '#' + h.attr('saveid'));
// add a data attribute so that other code (e.g. collapsible_headings) can use it
a.attr('data-toc-modified-id', h.attr('id'));
// get the text *excluding* the link text, whatever it may be
Expand Down Expand Up @@ -95,7 +95,7 @@ var make_link = function(h, num_lbl) {
}
var elt = ll[ll.length - 1]
if (elt) {
var highlighted_item = $(toc).find('a[href="#' + elt.id + '"]')
var highlighted_item = $(toc).find('a[href="' + window.location.href.split('#')[0] + '#' + elt.id + '"]')
if (evt.type == "execute") {
// remove the selected class and add execute class
// il the cell is selected again, it will be highligted as selected+running
Expand Down Expand Up @@ -689,4 +689,4 @@ if (!(require.specified('base/js/namespace'))) {
return toc2.table_of_contents(cfg, st);
});
}
}
}

0 comments on commit e43e7a2

Please sign in to comment.