summaryrefslogtreecommitdiffstats
path: root/lib/page/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/page/index.js')
-rw-r--r--lib/page/index.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/page/index.js b/lib/page/index.js
index 282cffe..e96f89b 100644
--- a/lib/page/index.js
+++ b/lib/page/index.js
@@ -4,6 +4,7 @@ var parsers = require('gitbook-parsers');
var error = require('../utils/error');
var pathUtil = require('../utils/path');
+var location = require('../utils/location');
var HTMLPipeline = require('./html');
/*
@@ -62,6 +63,21 @@ Page.prototype.outputPath = function(ext) {
return output;
};
+// Resolve a filename relative to this page
+// It returns a path relative to the book root folder
+Page.prototype.resolveLocal = function() {
+ var dir = path.dirname(this.path);
+ var file = path.join.apply(path, _.toArray(arguments));
+
+ return location.toAbsolute(file, dir, '');
+};
+
+// Resolve a filename relative to this page
+// It returns an absolute path for the FS
+Page.prototype.resolve = function() {
+ return this.book.resolve(this.resolveLocal.apply(this, arguments));
+};
+
// Update content of the page
Page.prototype.update = function(content) {
this.content = content;
@@ -118,8 +134,8 @@ Page.prototype.parse = function(output) {
// Normalize HTML output
.then(function() {
var pipelineOpts = {
- // Replace links to page of summary
onRelativeLink: _.partial(output.onRelativeLink, that),
+ onImage: _.partial(output.onOutputImage, that),
onOutputSVG: _.partial(output.onOutputSVG, that)
};
var pipeline = new HTMLPipeline(that.content, pipelineOpts);