diff options
Diffstat (limited to 'lib/parse/renderer.js')
-rw-r--r-- | lib/parse/renderer.js | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js index 86576f0..6b45a22 100644 --- a/lib/parse/renderer.js +++ b/lib/parse/renderer.js @@ -46,16 +46,12 @@ GitBookRenderer.prototype.link = function(href, title, text) { var o = this._extra_options; // Relative link, rewrite it to point to github repo if(!parsed.protocol && parsed.path && parsed.path[0] != '/' && o && o.repo && o.dir) { - href = 'https://github.com/' + o.repo + '/blob' + path.normalize(path.join( - '/', - o.dir, - href - )); + href = url.resolve('https://github.com/' + o.repo + '/blob/', [o.dir, href].join("/")); parsed = url.parse(href); } // Generate HTML for link - var out = '<a href="' + href + '"'; + var out = '<a href="' + parsed.href + '"'; // Title if no null if (title) { out += ' title="' + title + '"'; @@ -80,10 +76,8 @@ 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) { - _href = path.relative(o.outdir, path.normalize(path.join( - o.dir, - href - ))); + var outdir = o.outdir.charAt(o.outdir.length - 1) === '/' ? o.outdir : o.outdir + '/'; + _href = url.resolve(outdir, [o.dir, href].join('/')); } return GitBookRenderer.super_.prototype.image.call(this, _href, title, text); |