|
@@ -1,4 +1,5 @@
|
|
var Prism = require('prismjs');
|
|
var Prism = require('prismjs');
|
|
|
|
+var cheerio = require('cheerio');
|
|
|
|
|
|
module.exports = {
|
|
module.exports = {
|
|
book: {
|
|
book: {
|
|
@@ -9,15 +10,17 @@ module.exports = {
|
|
},
|
|
},
|
|
hooks: {
|
|
hooks: {
|
|
page: function (page) {
|
|
page: function (page) {
|
|
- var $ = cheerio.load(page.content);
|
|
|
|
|
|
+ page.sections.forEach(function (section) {
|
|
|
|
+ var $ = cheerio.load(section.content);
|
|
|
|
|
|
- $('code').each(function() {
|
|
|
|
- var text = $(this).text();
|
|
|
|
- var highlighted = Prism.highlight(text, Prism.languages.javascript);
|
|
|
|
- $(this).html(highlighted);
|
|
|
|
- });
|
|
|
|
|
|
+ $('code').each(function() {
|
|
|
|
+ var text = $(this).text();
|
|
|
|
+ var highlighted = Prism.highlight(text, Prism.languages.javascript);
|
|
|
|
+ $(this).html(highlighted);
|
|
|
|
+ });
|
|
|
|
|
|
- page.content = $.html();
|
|
|
|
|
|
+ section.content = $.html();
|
|
|
|
+ });
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
}
|
|
}
|