{"action":"created","comment":{"url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/comments/53671982","id":53671982,"diff_hunk":"@@ -274,77 +273,60 @@ var table_of_contents = function () {\n     //proces_cell_toc();\n     \n     var cell_toc_text = \"# Table of Contents\\n <p>\";\n-    var depth = 1;\n-    var li;\n-    $(\"#notebook\").find(\":header\").map(function (i, h) {\n-      var level = parseInt(h.tagName.slice(1), 10);\n+    var depth = 1; //var depth = ol_depth(ol);\n+    var li= ul;//yes, initialize li with ul! \n+    var all_headers= $(\"#notebook\").find(\":header\");\n+    var min_lvl=1, lbl_ary= [];\n+    for(; min_lvl <= 6; min_lvl++){ if(all_headers.is('h'+min_lvl)){break;} }\n+    for(var i= min_lvl; i <= 6; i++){ lbl_ary[i - min_lvl]= 0; }\n+\n+    //loop over all headers\n+    all_headers.each(function (i, h) {\n+      var level = parseInt(h.tagName.slice(1), 10) - min_lvl + 1;\n       // skip below threshold\n-      if (level > threshold) return;\n+      if (level > threshold){ return; }\n       // skip headings with no ID to link to\n-      if (!h.id) return;\n+      if (!h.id){ return; }","path":"nbextensions/usability/toc2/main.js","position":238,"original_position":238,"commit_id":"13c4463dc04eeb4736bbd43ed0046ae8cba76c57","original_commit_id":"13c4463dc04eeb4736bbd43ed0046ae8cba76c57","user":{"login":"jfbercher","id":7596356,"avatar_url":"https://avatars.githubusercontent.com/u/7596356?v=3","gravatar_id":"","url":"https://api.github.com/users/jfbercher","html_url":"https://github.com/jfbercher","followers_url":"https://api.github.com/users/jfbercher/followers","following_url":"https://api.github.com/users/jfbercher/following{/other_user}","gists_url":"https://api.github.com/users/jfbercher/gists{/gist_id}","starred_url":"https://api.github.com/users/jfbercher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfbercher/subscriptions","organizations_url":"https://api.github.com/users/jfbercher/orgs","repos_url":"https://api.github.com/users/jfbercher/repos","events_url":"https://api.github.com/users/jfbercher/events{/privacy}","received_events_url":"https://api.github.com/users/jfbercher/received_events","type":"User","site_admin":false},"body":"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","created_at":"2016-02-22T18:49:44Z","updated_at":"2016-02-22T18:49:44Z","html_url":"https://github.com/ipython-contrib/IPython-notebook-extensions/pull/472#discussion_r53671982","pull_request_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/472","_links":{"self":{"href":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/comments/53671982"},"html":{"href":"https://github.com/ipython-contrib/IPython-notebook-extensions/pull/472#discussion_r53671982"},"pull_request":{"href":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/472"}}},"pull_request":{"url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/472","id":59280036,"html_url":"https://github.com/ipython-contrib/IPython-notebook-extensions/pull/472","diff_url":"https://github.com/ipython-contrib/IPython-notebook-extensions/pull/472.diff","patch_url":"https://github.com/ipython-contrib/IPython-notebook-extensions/pull/472.patch","issue_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/issues/472","number":472,"state":"closed","locked":false,"title":"nbextensions/usability/toc2/: Fixed problems with skipped heading levels,  nested TOC lists","user":{"login":"slonik-az","id":11963186,"avatar_url":"https://avatars.githubusercontent.com/u/11963186?v=3","gravatar_id":"","url":"https://api.github.com/users/slonik-az","html_url":"https://github.com/slonik-az","followers_url":"https://api.github.com/users/slonik-az/followers","following_url":"https://api.github.com/users/slonik-az/following{/other_user}","gists_url":"https://api.github.com/users/slonik-az/gists{/gist_id}","starred_url":"https://api.github.com/users/slonik-az/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slonik-az/subscriptions","organizations_url":"https://api.github.com/users/slonik-az/orgs","repos_url":"https://api.github.com/users/slonik-az/repos","events_url":"https://api.github.com/users/slonik-az/events{/privacy}","received_events_url":"https://api.github.com/users/slonik-az/received_events","type":"User","site_admin":false},"body":"* Table of Contents was empty when the first heading is `<h2>` or higher.\r\n* TOC had incorrectly numbered labels when some heading levels are skipped over.\r\n* Make calculations of numbered labels more robust.\r\n* Minor code cleanup","created_at":"2016-02-13T22:28:39Z","updated_at":"2016-02-22T18:49:44Z","closed_at":"2016-02-21T17:24:49Z","merged_at":"2016-02-21T17:24:49Z","merge_commit_sha":"119f96492ffb05e635c83dc2b28b5dcda62a5545","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/472/commits","review_comments_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/472/comments","review_comment_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/issues/472/comments","statuses_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/statuses/13c4463dc04eeb4736bbd43ed0046ae8cba76c57","head":{"label":"slonik-az:toc2-fix","ref":"toc2-fix","sha":"13c4463dc04eeb4736bbd43ed0046ae8cba76c57","user":{"login":"slonik-az","id":11963186,"avatar_url":"https://avatars.githubusercontent.com/u/11963186?v=3","gravatar_id":"","url":"https://api.github.com/users/slonik-az","html_url":"https://github.com/slonik-az","followers_url":"https://api.github.com/users/slonik-az/followers","following_url":"https://api.github.com/users/slonik-az/following{/other_user}","gists_url":"https://api.github.com/users/slonik-az/gists{/gist_id}","starred_url":"https://api.github.com/users/slonik-az/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slonik-az/subscriptions","organizations_url":"https://api.github.com/users/slonik-az/orgs","repos_url":"https://api.github.com/users/slonik-az/repos","events_url":"https://api.github.com/users/slonik-az/events{/privacy}","received_events_url":"https://api.github.com/users/slonik-az/received_events","type":"User","site_admin":false},"repo":{"id":49876180,"name":"IPython-notebook-extensions","full_name":"slonik-az/IPython-notebook-extensions","owner":{"login":"slonik-az","id":11963186,"avatar_url":"https://avatars.githubusercontent.com/u/11963186?v=3","gravatar_id":"","url":"https://api.github.com/users/slonik-az","html_url":"https://github.com/slonik-az","followers_url":"https://api.github.com/users/slonik-az/followers","following_url":"https://api.github.com/users/slonik-az/following{/other_user}","gists_url":"https://api.github.com/users/slonik-az/gists{/gist_id}","starred_url":"https://api.github.com/users/slonik-az/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slonik-az/subscriptions","organizations_url":"https://api.github.com/users/slonik-az/orgs","repos_url":"https://api.github.com/users/slonik-az/repos","events_url":"https://api.github.com/users/slonik-az/events{/privacy}","received_events_url":"https://api.github.com/users/slonik-az/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/slonik-az/IPython-notebook-extensions","description":"Some js extension for IPython notebook","fork":true,"url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions","forks_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/forks","keys_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/teams","hooks_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/hooks","issue_events_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/issues/events{/number}","events_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/events","assignees_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/assignees{/user}","branches_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/branches{/branch}","tags_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/tags","blobs_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/statuses/{sha}","languages_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/languages","stargazers_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/stargazers","contributors_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/contributors","subscribers_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/subscribers","subscription_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/subscription","commits_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/contents/{+path}","compare_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/merges","archive_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/downloads","issues_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/issues{/number}","pulls_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/pulls{/number}","milestones_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/milestones{/number}","notifications_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/labels{/name}","releases_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/releases{/id}","deployments_url":"https://api.github.com/repos/slonik-az/IPython-notebook-extensions/deployments","created_at":"2016-01-18T12:43:52Z","updated_at":"2016-01-18T12:43:53Z","pushed_at":"2016-02-13T22:17:58Z","git_url":"git://github.com/slonik-az/IPython-notebook-extensions.git","ssh_url":"git@github.com:slonik-az/IPython-notebook-extensions.git","clone_url":"https://github.com/slonik-az/IPython-notebook-extensions.git","svn_url":"https://github.com/slonik-az/IPython-notebook-extensions","homepage":null,"size":15646,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ipython-contrib:master","ref":"master","sha":"0d37be679df29807a14d81699f61119d49a51e50","user":{"login":"ipython-contrib","id":3129808,"avatar_url":"https://avatars.githubusercontent.com/u/3129808?v=3","gravatar_id":"","url":"https://api.github.com/users/ipython-contrib","html_url":"https://github.com/ipython-contrib","followers_url":"https://api.github.com/users/ipython-contrib/followers","following_url":"https://api.github.com/users/ipython-contrib/following{/other_user}","gists_url":"https://api.github.com/users/ipython-contrib/gists{/gist_id}","starred_url":"https://api.github.com/users/ipython-contrib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipython-contrib/subscriptions","organizations_url":"https://api.github.com/users/ipython-contrib/orgs","repos_url":"https://api.github.com/users/ipython-contrib/repos","events_url":"https://api.github.com/users/ipython-contrib/events{/privacy}","received_events_url":"https://api.github.com/users/ipython-contrib/received_events","type":"Organization","site_admin":false},"repo":{"id":11391151,"name":"IPython-notebook-extensions","full_name":"ipython-contrib/IPython-notebook-extensions","owner":{"login":"ipython-contrib","id":3129808,"avatar_url":"https://avatars.githubusercontent.com/u/3129808?v=3","gravatar_id":"","url":"https://api.github.com/users/ipython-contrib","html_url":"https://github.com/ipython-contrib","followers_url":"https://api.github.com/users/ipython-contrib/followers","following_url":"https://api.github.com/users/ipython-contrib/following{/other_user}","gists_url":"https://api.github.com/users/ipython-contrib/gists{/gist_id}","starred_url":"https://api.github.com/users/ipython-contrib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipython-contrib/subscriptions","organizations_url":"https://api.github.com/users/ipython-contrib/orgs","repos_url":"https://api.github.com/users/ipython-contrib/repos","events_url":"https://api.github.com/users/ipython-contrib/events{/privacy}","received_events_url":"https://api.github.com/users/ipython-contrib/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ipython-contrib/IPython-notebook-extensions","description":"Some js extension for IPython notebook","fork":false,"url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions","forks_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/forks","keys_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/teams","hooks_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/hooks","issue_events_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/issues/events{/number}","events_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/events","assignees_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/assignees{/user}","branches_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/branches{/branch}","tags_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/tags","blobs_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/statuses/{sha}","languages_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/languages","stargazers_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/stargazers","contributors_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/contributors","subscribers_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/subscribers","subscription_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/subscription","commits_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/contents/{+path}","compare_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/merges","archive_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/downloads","issues_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/issues{/number}","pulls_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls{/number}","milestones_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/milestones{/number}","notifications_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/labels{/name}","releases_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/releases{/id}","deployments_url":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/deployments","created_at":"2013-07-13T17:05:16Z","updated_at":"2016-02-21T23:01:08Z","pushed_at":"2016-02-22T18:45:38Z","git_url":"git://github.com/ipython-contrib/IPython-notebook-extensions.git","ssh_url":"git@github.com:ipython-contrib/IPython-notebook-extensions.git","clone_url":"https://github.com/ipython-contrib/IPython-notebook-extensions.git","svn_url":"https://github.com/ipython-contrib/IPython-notebook-extensions","homepage":null,"size":16720,"stargazers_count":466,"watchers_count":466,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":168,"mirror_url":null,"open_issues_count":60,"forks":168,"open_issues":60,"watchers":466,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/472"},"html":{"href":"https://github.com/ipython-contrib/IPython-notebook-extensions/pull/472"},"issue":{"href":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/issues/472"},"comments":{"href":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/issues/472/comments"},"review_comments":{"href":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/472/comments"},"review_comment":{"href":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/pulls/472/commits"},"statuses":{"href":"https://api.github.com/repos/ipython-contrib/IPython-notebook-extensions/statuses/13c4463dc04eeb4736bbd43ed0046ae8cba76c57"}}}}