diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-19 09:47:36 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-19 09:47:36 +0100 |
commit | ec586dd3cdf06e9567f5d3e4961022ddc3c94778 (patch) | |
tree | cc7825ab73110b4e6fbedee404427b052edffa17 /lib/utils | |
parent | 80432161708357bdcf0e00533d9e6d327636dab6 (diff) | |
download | gitbook-ec586dd3cdf06e9567f5d3e4961022ddc3c94778.zip gitbook-ec586dd3cdf06e9567f5d3e4961022ddc3c94778.tar.gz gitbook-ec586dd3cdf06e9567f5d3e4961022ddc3c94778.tar.bz2 |
Clear folder
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/index.js | 4 | ||||
-rw-r--r-- | lib/utils/lang.js | 19 | ||||
-rw-r--r-- | lib/utils/links.js | 60 | ||||
-rw-r--r-- | lib/utils/string.js | 26 |
4 files changed, 0 insertions, 109 deletions
diff --git a/lib/utils/index.js b/lib/utils/index.js deleted file mode 100644 index dbc4087..0000000 --- a/lib/utils/index.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - lang: require('./lang'), - links: require('./links') -}; diff --git a/lib/utils/lang.js b/lib/utils/lang.js deleted file mode 100644 index 9da737b..0000000 --- a/lib/utils/lang.js +++ /dev/null @@ -1,19 +0,0 @@ -var MAP = { - 'py': 'python', - 'js': 'javascript', - 'rb': 'ruby', - 'csharp': 'cs', -}; - -function normalize(lang) { - if(!lang) { return null; } - - var lower = lang.toLowerCase(); - return MAP[lower] || lower; -} - -// Exports -module.exports = { - normalize: normalize, - MAP: MAP -}; diff --git a/lib/utils/links.js b/lib/utils/links.js deleted file mode 100644 index b4d2fb7..0000000 --- a/lib/utils/links.js +++ /dev/null @@ -1,60 +0,0 @@ -var url = require('url'); -var path = require('path'); - -// Is the link an external link -var isExternal = function(href) { - try { - return Boolean(url.parse(href).protocol); - } catch(err) { } - - return false; -}; - -// Return true if the link is relative -var isRelative = function(href) { - try { - var parsed = url.parse(href); - - return !parsed.protocol && parsed.path && parsed.path[0] != '/'; - } catch(err) {} - - return true; -}; - -// Relative to absolute path -// dir: directory parent of the file currently in rendering process -// outdir: directory parent from the html output - -var toAbsolute = function(_href, dir, outdir) { - // Absolute file in source - _href = path.join(dir, _href); - - // make it relative to output - _href = path.relative(outdir, _href); - - if (process.platform === 'win32') { - _href = _href.replace(/\\/g, '/'); - } - - return _href; -}; - -// Join links - -var join = function() { - var _href = path.join.apply(path, arguments); - - if (process.platform === 'win32') { - _href = _href.replace(/\\/g, '/'); - } - - return _href; -}; - - -module.exports = { - isRelative: isRelative, - isExternal: isExternal, - toAbsolute: toAbsolute, - join: join -}; diff --git a/lib/utils/string.js b/lib/utils/string.js deleted file mode 100644 index 54c4c66..0000000 --- a/lib/utils/string.js +++ /dev/null @@ -1,26 +0,0 @@ -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 || value === false) return null; - if (value === true) return key; - return key+"="+escapeShellArg(value); - }) - .compact() - .value() - .join(" "); -} - -module.exports = { - escapeShellArg: escapeShellArg, - optionsToShellArgs: optionsToShellArgs -}; |