summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/utils/links.js16
-rw-r--r--lib/utils/page.js4
-rw-r--r--package.json2
3 files changed, 12 insertions, 10 deletions
diff --git a/lib/utils/links.js b/lib/utils/links.js
index aa7c241..61cdc9a 100644
--- a/lib/utils/links.js
+++ b/lib/utils/links.js
@@ -31,6 +31,11 @@ var isAnchor = function(href) {
return false;
};
+// Normalize a path to be a link
+var normalizeLink = function(s) {
+ return s.replace(/\\/g, '/');
+};
+
// Relative to absolute path
// dir: directory parent of the file currently in rendering process
// outdir: directory parent from the html output
@@ -46,7 +51,7 @@ var toAbsolute = function(_href, dir, outdir) {
_href = path.relative(outdir, hrefInRoot);
// Normalize windows paths
- _href = _href.replace(/\\/g, '/');
+ _href = normalizeLink(_href);
return _href;
};
@@ -55,11 +60,7 @@ var toAbsolute = function(_href, dir, outdir) {
var join = function() {
var _href = path.join.apply(path, arguments);
- if (process.platform === 'win32') {
- _href = _href.replace(/\\/g, '/');
- }
-
- return _href;
+ return normalizeLink(_href);
};
// Change extension
@@ -76,5 +77,6 @@ module.exports = {
isExternal: isExternal,
toAbsolute: toAbsolute,
join: join,
- changeExtension: changeExtension
+ changeExtension: changeExtension,
+ normalize: normalizeLink
};
diff --git a/lib/utils/page.js b/lib/utils/page.js
index effa24f..71012ba 100644
--- a/lib/utils/page.js
+++ b/lib/utils/page.js
@@ -145,7 +145,7 @@ function normalizeHtml(src, options) {
var dest = "";
// Replace extension
- dest = path.join(path.dirname(srcAbs), path.basename(srcAbs, ext)+".png");
+ dest = links.join(path.dirname(srcAbs), path.basename(srcAbs, ext)+".png");
dest = dest[0] == "/"? dest.slice(1) : dest;
// Get a name that doesn't exists
@@ -164,7 +164,7 @@ function normalizeHtml(src, options) {
dest: path.join("./", dest)
});
- src = path.join("/", dest);
+ src = links.join("/", dest);
}
// Reset as relative to output
diff --git a/package.json b/package.json
index 58468a3..c40f25c 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
"lodash": "3.2.0",
"graceful-fs": "3.0.5",
"resolve": "0.6.3",
- "fs-extra": "0.16.3",
+ "fs-extra": "0.16.5",
"fstream-ignore": "1.0.2",
"gitbook-parsers": "0.5.2",
"nunjucks": "git+https://github.com/mozilla/nunjucks.git#42d2b9f5c0ad5db8ca3a1fdbba5bde9fc4cc2c45",