Merge pull request #3064 from minrk/header-anchors

add anchors to heading cells
This commit is contained in:
Matthias Bussonnier 2013-04-01 07:08:28 -07:00
commit 061d27e877
3 changed files with 20 additions and 1 deletions

View File

@ -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'));

View File

@ -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($('<h'+this.level+'/>').html(text));
r.append(
$('<h'+this.level+'/>')
.append(
$('<a/>')
.addClass('heading-anchor')
.attr('href', '#' + text)
.attr('name', text)
.html(text)
)
);
};

View File

@ -468,3 +468,8 @@ p {
margin-bottom:0;
}
a.heading-anchor:link {
text-decoration: none;
color: inherit;
}