diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-04-23 17:10:16 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-04-23 17:10:16 +0200 |
commit | e1fa977b5b1b3c03790de6e2c21ee39ba55d9555 (patch) | |
tree | a1ad4386100b5779ef930845093c14639a3353b5 /lib/output/json/onPage.js | |
parent | ce95f316b9ce1eac1e615db3540c4d0f30408d63 (diff) | |
download | gitbook-e1fa977b5b1b3c03790de6e2c21ee39ba55d9555.zip gitbook-e1fa977b5b1b3c03790de6e2c21ee39ba55d9555.tar.gz gitbook-e1fa977b5b1b3c03790de6e2c21ee39ba55d9555.tar.bz2 |
Add json encoding utils
Diffstat (limited to 'lib/output/json/onPage.js')
-rw-r--r-- | lib/output/json/onPage.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/output/json/onPage.js b/lib/output/json/onPage.js index 3ef5c74..a84e297 100644 --- a/lib/output/json/onPage.js +++ b/lib/output/json/onPage.js @@ -1,4 +1,6 @@ +var JSONUtils = require('../../json'); var Modifier = require('../modifier'); +var Writer = require('../writer'); /** Write a page as a json file @@ -7,13 +9,22 @@ var Modifier = require('../modifier'); @param {Page} page */ function onPage(output, page) { - var options = output. - - return Modifier.applyHTMLTransformations(page, [ + return Modifier.modifyHTML(page, [ Modifier.HTML.resolveLinks() ]) - .then(function(newPage) { + .then(function(resultPage) { + // Generate the JSON + var json = JSONUtils.encodeBookWithPage(output.getBook(), resultPage); + // Write it to the disk + return Writer.writePage( + output, + page, + JSON.stringify(json, null, 4), + { + extension: '.json' + } + ); }); } |