Skip to content

Commit c388b21

Browse files
louisabrahamjcb91
authored andcommitted
New optional feature to skip the first header of a notebook in the TOC
1 parent b0937b8 commit c388b21

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/jupyter_contrib_nbextensions/nbextensions/toc2/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The initial configuration can be given using the IPython-contrib nbextensions fa
2929
- Widening the display area to fit the browser window (may be useful with sidebar option; default: true)
3030
- The numbering of headers (true by default)
3131
- Moving header title and menus on the left (default: true)
32+
- Skipping the first header (useful if you want to display a title): set `skipTitle` to true in the notebook's metadata (default: false)
3233
- Customization of highlighting the title of currently selected/running sections.
3334
- Customization of background, fonts, border and highlighting colors in the toc window and navigation menus (as third demo).
3435

src/jupyter_contrib_nbextensions/nbextensions/toc2/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ define(["require", "jquery", "base/js/namespace", 'services/config',
3232
'sidebar_border': '#EEEEEE',
3333
'navigate_text': '#333333',
3434
'navigate_num': '#000000',
35-
}
35+
},
36+
'skipTitle': false
3637
}
3738

3839
//.....................global variables....

src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ var table_of_contents = function (cfg,st) {
541541
//loop over all headers
542542
all_headers.each(function (i, h) {
543543
var level = parseInt(h.tagName.slice(1), 10) - min_lvl + 1;
544+
// skip title if necessary
545+
if (cfg.skipTitle &&!i){ return; }
544546
// skip below threshold
545547
if (level > cfg.threshold){ return; }
546548
// skip headings with no ID to link to

0 commit comments

Comments
 (0)