diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-19 18:49:02 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-19 18:49:02 +0100 |
commit | 6344928580e521974508d445238c207aecec299b (patch) | |
tree | ecf21b32a777115b4fdec1adbdbd7ec987adbd7d /lib/generators/json.js | |
parent | 2dbf9b0d4a88a6461ca60f49f3d66ccd42143be3 (diff) | |
download | gitbook-6344928580e521974508d445238c207aecec299b.zip gitbook-6344928580e521974508d445238c207aecec299b.tar.gz gitbook-6344928580e521974508d445238c207aecec299b.tar.bz2 |
Write file in json generator
Diffstat (limited to 'lib/generators/json.js')
-rw-r--r-- | lib/generators/json.js | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/lib/generators/json.js b/lib/generators/json.js index 661e587..3023b42 100644 --- a/lib/generators/json.js +++ b/lib/generators/json.js @@ -17,33 +17,25 @@ Generator.prototype.transferFile = function(input) { }; Generator.prototype.finish = function() { }; // Convert an input file -Generator.prototype.convertFile = function(content, input) { +Generator.prototype.writeParsedFile = function(page, input) { var that = this; var json = { - progress: parse.progress(this.options.navigation, input) + progress: [], + sections: page.sections }; - return Q() - .then(function() { - return parse.page(content, { - dir: path.dirname(input) || '/' - }); - }) - .then(function(parsed) { - json.lexed = parsed.lexed; - json.sections = parsed.sections; - }) - .then(function() { - return fs.writeFile( - path.join(that.options.output, input.replace(".md", ".json")), - JSON.stringify(json, null, 4) - ); - }); + var output = path.basename(input, path.extname(input))+".json"; + output = path.join(that.options.output, output); + + return fs.writeFile( + output, + JSON.stringify(json, null, 4) + ); }; // Generate languages index // Contains the first languages readme and langs infos -Generator.prototype.langsIndex = function(langs) { +/*Generator.prototype.langsIndex = function(langs) { var that = this; if (langs.list.length == 0) return Q.reject("Need at least one language"); @@ -68,6 +60,6 @@ Generator.prototype.langsIndex = function(langs) { JSON.stringify(json, null, 4) ); }); -}; +};*/ module.exports = Generator; |