diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-05-29 18:28:09 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-05-29 18:28:09 +0200 |
commit | f4a17b182fb28f686693659983d82797ce93330b (patch) | |
tree | 7e53cec1b9db40190939f8e22a845d4fa2d5b865 /lib/utils/string.js | |
parent | 5c3b345fa69f577ebcc752ad626cd60f6bd412c6 (diff) | |
download | gitbook-f4a17b182fb28f686693659983d82797ce93330b.zip gitbook-f4a17b182fb28f686693659983d82797ce93330b.tar.gz gitbook-f4a17b182fb28f686693659983d82797ce93330b.tar.bz2 |
Improve ebook generation (toc, ...)
Diffstat (limited to 'lib/utils/string.js')
-rw-r--r-- | lib/utils/string.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/utils/string.js b/lib/utils/string.js new file mode 100644 index 0000000..52cbd3d --- /dev/null +++ b/lib/utils/string.js @@ -0,0 +1,25 @@ +var _ = require("lodash"); + +function escapeShellArg(arg) { + var ret = ''; + + ret = arg.replace(/"/g, '\\"'); + + return "\"" + ret + "\""; +} + +function optionsToShellArgs(options) { + return _.chain(options) + .map(function(value, key) { + if (value == null) return null; + return key+"="+escapeShellArg(value); + }) + .compact() + .value() + .join(" "); +} + +module.exports = { + escapeShellArg: escapeShellArg, + optionsToShellArgs: optionsToShellArgs +}; |