Fix image path calcul

This commit is contained in:
Samy Pessé
2014-04-18 17:15:03 +02:00
parent ef4a8ea1b6
commit b5bb953e47
+8 -2
View File
@@ -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);