diff --git a/IPython/frontend/html/notebook/static/js/notebookmain.js b/IPython/frontend/html/notebook/static/js/notebookmain.js index 297822dba..64ffd9508 100644 --- a/IPython/frontend/html/notebook/static/js/notebookmain.js +++ b/IPython/frontend/html/notebook/static/js/notebookmain.js @@ -82,6 +82,11 @@ $(document).ready(function () { IPython.layout_manager.do_resize(); $([IPython.events]).on('notebook_loaded.Notebook', function () { IPython.layout_manager.do_resize(); + var hash = document.location.hash; + if (hash) { + document.location.hash = ''; + document.location.hash = hash; + } }); IPython.notebook.load_notebook($('body').data('notebookId')); diff --git a/IPython/frontend/html/notebook/static/js/textcell.js b/IPython/frontend/html/notebook/static/js/textcell.js index 65d96a0a5..fee6a4443 100644 --- a/IPython/frontend/html/notebook/static/js/textcell.js +++ b/IPython/frontend/html/notebook/static/js/textcell.js @@ -516,7 +516,16 @@ var IPython = (function (IPython) { HeadingCell.prototype.set_rendered = function (text) { var r = this.element.find("div.text_cell_render"); r.empty(); - r.append($('').html(text)); + r.append( + $('') + .append( + $('') + .addClass('heading-anchor') + .attr('href', '#' + text) + .attr('name', text) + .html(text) + ) + ); }; diff --git a/IPython/frontend/html/notebook/static/less/notebook.less b/IPython/frontend/html/notebook/static/less/notebook.less index acedafdac..6c9a0d54f 100644 --- a/IPython/frontend/html/notebook/static/less/notebook.less +++ b/IPython/frontend/html/notebook/static/less/notebook.less @@ -468,3 +468,8 @@ p { margin-bottom:0; } + +a.heading-anchor:link { + text-decoration: none; + color: inherit; +}