diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-05-29 18:33:05 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-05-29 18:33:05 +0200 |
commit | 9f00bf80604d49527ec057e4afc0f47612ad025b (patch) | |
tree | 6173bd52388329862fbf525158cc6949d39099eb /lib | |
parent | f4a17b182fb28f686693659983d82797ce93330b (diff) | |
download | gitbook-9f00bf80604d49527ec057e4afc0f47612ad025b.zip gitbook-9f00bf80604d49527ec057e4afc0f47612ad025b.tar.gz gitbook-9f00bf80604d49527ec057e4afc0f47612ad025b.tar.bz2 |
Add toc at the end of pdf
Diffstat (limited to 'lib')
-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() |