summaryrefslogtreecommitdiffstats
path: root/lib/parse
diff options
context:
space:
mode:
Diffstat (limited to 'lib/parse')
-rw-r--r--lib/parse/renderer.js24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js
index 64c5602..848f6e3 100644
--- a/lib/parse/renderer.js
+++ b/lib/parse/renderer.js
@@ -45,7 +45,7 @@ GitBookRenderer.prototype.link = function(href, title, text) {
var o = this._extra_options;
// Relative link, rewrite it to point to github repo
- if(parsed.path[0] != '/' && o && o.repo && o.dir) {
+ if(!parsed.protocol && parsed.path[0] != '/' && o && o.repo && o.dir) {
href = 'https://github.com/' + o.repo + '/blob' + path.normalize(path.join(
'/',
o.dir,
@@ -68,5 +68,27 @@ GitBookRenderer.prototype.link = function(href, title, text) {
return out;
};
+GitBookRenderer.prototype.image = function(href, title, text) {
+ // Our "fixed" href
+ var _href = href;
+
+ // Parsed version of the url
+ var parsed = url.parse(href);
+
+ // Options
+ var o = this._extra_options;
+
+ // Relative image, rewrite it depending output
+ if(!parsed.protocol && parsed.path[0] != '/' && o && o.dir && o.outdir) {
+ _href = path.relative(o.outdir, path.normalize(path.join(
+ o.dir,
+ href
+ )));
+ }
+
+ return GitBookRenderer.super_.prototype.image.call(this, _href, title, text);
+};
+
+
// Exports
module.exports = GitBookRenderer;