diff options
author | Jayaram R Pai | 2014-06-25 22:38:32 +0530 |
---|---|---|
committer | Jayaram R Pai | 2014-06-25 22:38:32 +0530 |
commit | 2ffab4fc7a26b89fa417cd094de77b304e8c09c1 (patch) | |
tree | 651f1ddd3c216a6fb44535df72014e1693dd9646 /custom.js | |
parent | 6b24ce16a2505a183021936ca4d7a351a48f2c9d (diff) | |
download | custom-2ffab4fc7a26b89fa417cd094de77b304e8c09c1.tar.gz custom-2ffab4fc7a26b89fa417cd094de77b304e8c09c1.tar.bz2 custom-2ffab4fc7a26b89fa417cd094de77b304e8c09c1.zip |
added more selector fallbacks
Diffstat (limited to 'custom.js')
-rw-r--r-- | custom.js | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -76,7 +76,12 @@ $([IPython.events]).on('notebook_loaded.Notebook', function(){ /* fetching chapter number */ var $first_text_cell = $(".text_cell:first"); - var chapter_name = $first_text_cell.find("h1").attr("id"); + /* chapter name string either in id or innerHTML */ + var chapter_name = ""; + chapter_name = $first_text_cell.find("h1").attr("id"); + if(!chapter_name) { + chapter_name = $first_text_cell.find("h1").html(); + } var numbers = chapter_name.match(regex).map(function(v) { return parseFloat(v); }); var chapter_number = Math.abs(numbers[0]); console.log("Chapter:" + chapter_number); @@ -84,7 +89,13 @@ $([IPython.events]).on('notebook_loaded.Notebook', function(){ $code_cell.each(function(index, element) { /* fetching example and page number */ var $current_text_cell = $(this).prev(); - var $heading = $current_text_cell.find("h2"); + /* code headings can be h2 or h3 */ + var $heading; + $heading = $current_text_cell.find("h2"); + if(!$heading.html()) { + $heading = $current_text_cell.find("h3").first(); + console.log("################ Head" + $heading.html()); + } var heading_text = $heading.html(); var numbers = heading_text.match(regex).map(function(v) { return parseFloat(v); }); var example_no = Math.abs(numbers[0]); |