| OLD | NEW |
| 1 $(document).ready(function() { | 1 $(document).ready(function() { |
| 2 var addPermalink = function() { | 2 var addPermalink = function() { |
| 3 if ($(this).hasClass('no-permalink')) { |
| 4 return; |
| 5 } |
| 3 $(this).addClass('has-permalink'); | 6 $(this).addClass('has-permalink'); |
| 4 $(this).append($('<a class="permalink" title="Permalink" href="#' + $(th
is).attr('id') + '">#</a>')); | 7 $(this).append($('<a class="permalink" title="Permalink" href="#' + $(th
is).attr('id') + '">#</a>')); |
| 5 }; | 8 }; |
| 6 | 9 |
| 7 $.each(['h2','h3','h4'], function(n, h) { $('.has-permalinks ' + h).each(addPe
rmalink); }); | 10 $.each(['h2','h3','h4'], function(n, h) { $('.has-permalinks ' + h).each(addPe
rmalink); }); |
| 8 | 11 |
| 9 // Add the `prettyprint` class to the blocks of code specified in the way that | 12 // Add the `prettyprint` class to the blocks of code specified in the way that |
| 10 // the book pages use. | 13 // the book pages use. |
| 11 $('pre.programlisting > em > span.remark, pre.screen > em > span.remark') | 14 $('pre.programlisting > em > span.remark, pre.screen > em > span.remark') |
| 12 .each(function(i, element) { | 15 .each(function(i, element) { |
| 13 var $element = $(element); | 16 var $element = $(element); |
| 14 var $programListing = $element.parent().parent(); | 17 var $programListing = $element.parent().parent(); |
| 15 $programListing.addClass('prettyprint'); | 18 $programListing.addClass('prettyprint'); |
| 16 // This regular expression is to test if this remark is of the right form to | 19 // This regular expression is to test if this remark is of the right form to |
| 17 // specify the language of the code block. | 20 // specify the language of the code block. |
| 18 var re = /^lang\-[a-z]+$/i; | 21 var re = /^lang\-[a-z]+$/i; |
| 19 if (re.test($element.text().trim())) { | 22 if (re.test($element.text().trim())) { |
| 20 $programListing.addClass($element.text().trim()); | 23 $programListing.addClass($element.text().trim()); |
| 21 } | 24 } |
| 22 }); | 25 }); |
| 23 | 26 |
| 24 // Add syntax highlighting. | 27 // Add syntax highlighting. |
| 25 prettyPrint(); | 28 prettyPrint(); |
| 26 }); | 29 }); |
| OLD | NEW |