Skip to content

nbextensions/usability/toc2/: Fixed problems with skipped heading levels, nested TOC lists #472

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

Merged
merged 1 commit into from
Feb 21, 2016

Conversation

slonik-az
Copy link
Contributor

  • Table of Contents was empty when the first heading is <h2> or higher.
  • TOC had incorrectly numbered labels when some heading levels are skipped over.
  • Make calculations of numbered labels more robust.
  • Minor code cleanup

* Table of Contents was empty when the first heading was <h2> or higher.
* TOC had incorrectly numbered lablels when some heading levels were skipped over.
* Use .each() instead of .map() in main.js
@slonik-az slonik-az closed this Feb 13, 2016
@slonik-az slonik-az changed the title nbextensions/usability/toc2/: Fixed problems with skipped headings and nested TOC lists nbextensions/usability/toc2/: Fixed problems with skipped heading levels, nested TOC lists Feb 13, 2016
@slonik-az slonik-az reopened this Feb 13, 2016
@jfbercher
Copy link
Member

Hi @slonik-az.
I have checked the code and tested your modifications. This is a nice work that largely improves over what I did. This is very useful -- I was myself annoyed to be forced to begin the notebook with a level-1 heading. Thanks.
@juhasch, I think that we can merge as is.

juhasch added a commit that referenced this pull request Feb 21, 2016
nbextensions/usability/toc2/: Fixed problems with skipped heading levels,  nested TOC lists
@juhasch juhasch merged commit d6aca2d into ipython-contrib:master Feb 21, 2016
// skip headings with no ID to link to
if (!h.id) return;
if (!h.id){ return; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW: IMO it would be nice to a) add IDs so that you wouldn't need to add them on your own if you display H1 from a kernel and b) to check that a ID wasn't already included in the list if if it was, do some magic that the links work anyways...

[The last is a problem when including something like this: "analysis 1": "plots", "stats"; analysis 2: "plots", "stats" -> the links for both "stats" all go to the first one because the notebook does not render unique IDs -> https://github.com/jupyter/notebook/issues/77]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally understood what is the actual problem... I did an essay to address it (since we number headings, we can try to use this number as a kind of unique marker). Of course external links may fail when toc changes but I suggest a way to address this too -- see #488

@slonik-az
Copy link
Contributor Author

@jfbercher, @juhasch:
Thanks for merging my patch into master! toc2 is a great extension which makes notebook navigation so much more fun. Making it more robust benefits everybody.
--Leo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants