diff options
-rw-r--r-- | lib/generate/ebook/index.js | 5 | ||||
-rw-r--r-- | lib/utils/string.js | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/generate/ebook/index.js b/lib/generate/ebook/index.js index 2d9c1ae..a02d877 100644 --- a/lib/generate/ebook/index.js +++ b/lib/generate/ebook/index.js @@ -29,6 +29,7 @@ Generator.prototype.finish = function() { return BaseGenerator.prototype.finish.apply(this) .then(function() { var d = Q.defer(); + var format = that.options.extension || path.extname(that.options.output); if (!that.options.cover && fs.existsSync(path.join(that.options.output, "cover.jpg"))) { that.options.cover = path.join(that.options.output, "cover.jpg"); @@ -44,6 +45,10 @@ Generator.prototype.finish = function() { "--level3-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]" }; + if (format == "pdf") { + _options["--pdf-add-toc"] = true; + } + var command = [ "ebook-convert", path.join(that.options.output, "index.html"), diff --git a/lib/utils/string.js b/lib/utils/string.js index 52cbd3d..63c5e91 100644 --- a/lib/utils/string.js +++ b/lib/utils/string.js @@ -12,6 +12,7 @@ function optionsToShellArgs(options) { return _.chain(options) .map(function(value, key) { if (value == null) return null; + if (value == true) return key; return key+"="+escapeShellArg(value); }) .compact() |