summaryrefslogtreecommitdiffstats
path: root/lib/generate/ebook/index.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-05-29 18:28:09 +0200
committerSamy Pessé <samypesse@gmail.com>2014-05-29 18:28:09 +0200
commitf4a17b182fb28f686693659983d82797ce93330b (patch)
tree7e53cec1b9db40190939f8e22a845d4fa2d5b865 /lib/generate/ebook/index.js
parent5c3b345fa69f577ebcc752ad626cd60f6bd412c6 (diff)
downloadgitbook-f4a17b182fb28f686693659983d82797ce93330b.zip
gitbook-f4a17b182fb28f686693659983d82797ce93330b.tar.gz
gitbook-f4a17b182fb28f686693659983d82797ce93330b.tar.bz2
Improve ebook generation (toc, ...)
Diffstat (limited to 'lib/generate/ebook/index.js')
-rw-r--r--lib/generate/ebook/index.js17
1 files changed, 8 insertions, 9 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) {