summaryrefslogtreecommitdiffstats
path: root/lib/generators/json.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-01-27 11:15:16 +0100
committerSamy Pessé <samypesse@gmail.com>2015-01-27 11:15:16 +0100
commit6125df58340456529cfb180cc62308cc00e4e769 (patch)
tree38cfe330153bc2bb8fcaef18cb446373ee0de0f9 /lib/generators/json.js
parent99cd3148ba99a7bf5afaa9b1bb51749411de9d18 (diff)
downloadgitbook-6125df58340456529cfb180cc62308cc00e4e769.zip
gitbook-6125df58340456529cfb180cc62308cc00e4e769.tar.gz
gitbook-6125df58340456529cfb180cc62308cc00e4e769.tar.bz2
Add back "page:before" hook
Diffstat (limited to 'lib/generators/json.js')
-rw-r--r--lib/generators/json.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/generators/json.js b/lib/generators/json.js
index a1202ad..f1af395 100644
--- a/lib/generators/json.js
+++ b/lib/generators/json.js
@@ -17,20 +17,24 @@ Generator.prototype.transferFile = function(input) { };
Generator.prototype.finish = function() { };
// Convert an input file
-Generator.prototype.writeParsedFile = function(page) {
+Generator.prototype.convertFile = function(input) {
var that = this;
- var json = {
- progress: page.progress,
- sections: page.sections
- };
- var output = links.changeExtension(page.path, ".json");
- output = path.join(that.options.output, output);
+ return that.book.parsePage(input)
+ .then(function(page) {
+ var json = {
+ progress: page.progress,
+ sections: page.sections
+ };
- return fs.writeFile(
- output,
- JSON.stringify(json, null, 4)
- );
+ var output = links.changeExtension(page.path, ".json");
+ output = path.join(that.options.output, output);
+
+ return fs.writeFile(
+ output,
+ JSON.stringify(json, null, 4)
+ );
+ });
};
// Generate languages index