diff options
Diffstat (limited to 'lib/generate')
-rw-r--r-- | lib/generate/ebook/index.js | 17 | ||||
-rw-r--r-- | lib/generate/page/index.js | 8 | ||||
-rw-r--r-- | lib/generate/site/index.js | 1 |
3 files changed, 16 insertions, 10 deletions
diff --git a/lib/generate/ebook/index.js b/lib/generate/ebook/index.js index 574341d..2d9c1ae 100644 --- a/lib/generate/ebook/index.js +++ b/lib/generate/ebook/index.js @@ -7,6 +7,7 @@ var exec = require('child_process').exec; var fs = require("fs"); var parse = require("../../parse"); var BaseGenerator = require("../page"); +var stringUtils = require("../../utils/string"); /* * This generator inherits from the single page generator @@ -35,21 +36,19 @@ Generator.prototype.finish = function() { var _options = { "--cover": that.options.cover, - "--chapter": "\"descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter ')]\"" + "--title": that.options.title, + "--comments": that.options.description, + "--authors": that.options.author, + "--level1-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-1 ')]", + "--level2-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-2 ')]", + "--level3-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]" }; var command = [ "ebook-convert", path.join(that.options.output, "index.html"), path.join(that.options.output, "index."+that.options.extension), - _.chain(_options) - .map(function(value, key) { - if (value == null) return null; - return key+"="+value; - }) - .compact() - .value() - .join(" ") + stringUtils.optionsToShellArgs(_options) ].join(" "); exec(command, function (error, stdout, stderr) { diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js index c2f4484..7e6826d 100644 --- a/lib/generate/page/index.js +++ b/lib/generate/page/index.js @@ -18,6 +18,11 @@ swig.setFilter('code', function(code, lang) { } }); +// Convert a level into a deep level +swig.setFilter('lvl', function(lvl) { + return lvl.split(".").length; +}); + /* * This generator will generate a simple index.html which can be converted as a PDF @@ -66,11 +71,14 @@ Generator.prototype.finish = function() { var basePath = "."; var output = path.join(this.options.output, "index.html"); + var progress = parse.progress(this.options.navigation, "README.md"); + return Q() // Generate html .then(function(pages) { return that._writeTemplate(that.template, { pages: that.pages, + progress: progress, basePath: basePath, staticBase: path.join(basePath, "gitbook"), diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index da65152..7146e8e 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -63,7 +63,6 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate) var that = this; interpolate = interpolate || _.identity; - return Q() .then(function(sections) { return tpl(_.extend({ |