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.js22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/page/index.js b/lib/page/index.js
index bdf3c81..bc12529 100644
--- a/lib/page/index.js
+++ b/lib/page/index.js
@@ -60,14 +60,23 @@ Page.prototype.resolve = function() {
return this.book.resolve(this.resolveLocal.apply(this, arguments));
};
-// Convert an absolite path to a relative path from this page
+// Convert an absolute path (in the book) to a relative path from this page
Page.prototype.relative = function(name) {
+ // Convert /test.png -> test.png
+ name = location.toAbsolute(name, '', '');
+
return location.relative(
- this.resolve('.'),
- this.resolve(name)
+ this.resolve('.') + '/',
+ this.book.resolve(name)
);
};
+// Return a page result of a relative page from this page
+Page.prototype.followPage = function(filename) {
+ var absPath = this.resolveLocal(filename);
+ return this.book.getPage(absPath);
+};
+
// Update content of the page
Page.prototype.update = function(content) {
this.content = content;
@@ -148,10 +157,7 @@ Page.prototype.toHTML = function(output) {
// Normalize HTML output
.then(function() {
var pipelineOpts = {
- onRelativeLink: function (href) {
- href = that.relative(href);
- return output.onRelativeLink(that, href);
- },
+ onRelativeLink: _.partial(output.onRelativeLink, that),
onImage: _.partial(output.onOutputImage, that),
onOutputSVG: _.partial(output.onOutputSVG, that),
@@ -166,7 +172,7 @@ Page.prototype.toHTML = function(output) {
},
// Convert glossary entries to annotations
- annotations: that.book.glosary.annotations()
+ annotations: that.book.glossary.annotations()
};
var pipeline = new HTMLPipeline(that.content, pipelineOpts);