summaryrefslogtreecommitdiff
path: root/custom.js
diff options
context:
space:
mode:
authorJayaram R Pai2014-06-25 22:38:32 +0530
committerJayaram R Pai2014-06-25 22:38:32 +0530
commit2ffab4fc7a26b89fa417cd094de77b304e8c09c1 (patch)
tree651f1ddd3c216a6fb44535df72014e1693dd9646 /custom.js
parent6b24ce16a2505a183021936ca4d7a351a48f2c9d (diff)
downloadcustom-2ffab4fc7a26b89fa417cd094de77b304e8c09c1.tar.gz
custom-2ffab4fc7a26b89fa417cd094de77b304e8c09c1.tar.bz2
custom-2ffab4fc7a26b89fa417cd094de77b304e8c09c1.zip
added more selector fallbacks
Diffstat (limited to 'custom.js')
-rw-r--r--custom.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/custom.js b/custom.js
index e47213e..f308f40 100644
--- a/custom.js
+++ b/custom.js
@@ -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]);