summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-18 17:15:03 +0200
committerSamy Pessé <samypesse@gmail.com>2014-04-18 17:15:03 +0200
commitb5bb953e4779a591ade83356ffbf776047c53f5b (patch)
tree3e862ec5e19a571ca55f2c31973c03436e0d4caa
parentef4a8ea1b6c4dfb9a84b5c2a3c933f2d6481814e (diff)
downloadgitbook-b5bb953e4779a591ade83356ffbf776047c53f5b.zip
gitbook-b5bb953e4779a591ade83356ffbf776047c53f5b.tar.gz
gitbook-b5bb953e4779a591ade83356ffbf776047c53f5b.tar.bz2
Fix image path calcul
-rw-r--r--lib/parse/renderer.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js
index 2a72d48..949a9ee 100644
--- a/lib/parse/renderer.js
+++ b/lib/parse/renderer.js
@@ -79,8 +79,14 @@ GitBookRenderer.prototype.image = function(href, title, text) {
// Relative image, rewrite it depending output
if(!parsed.protocol && parsed.path && parsed.path[0] != '/' && o && o.dir && o.outdir) {
- var outdir = o.outdir.charAt(o.outdir.length - 1) === '/' ? o.outdir : o.outdir + '/';
- _href = url.resolve(outdir, [o.dir, href].join('/'));
+ // o.dir: directory parent of the file currently in rendering process
+ // o.outdir: directory parent from the html output
+
+ // Absolute file in source
+ _href = path.join(o.dir, _href);
+
+ // make it relative to output
+ _href = path.relative(o.outdir, _href);
}
return GitBookRenderer.super_.prototype.image.call(this, _href, title, text);