summaryrefslogtreecommitdiffstats
path: root/lib/book.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/book.js')
-rw-r--r--lib/book.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/book.js b/lib/book.js
index 41b1d1a..27a609c 100644
--- a/lib/book.js
+++ b/lib/book.js
@@ -5,6 +5,7 @@ var path = require("path");
var fs = require("./utils/fs");
var parseNavigation = require("./utils/navigation");
var parseProgress = require("./utils/progress");
+var pageUtil = require("./utils/page");
var Configuration = require("./configuration");
var TemplateEngine = require("./template");
@@ -48,7 +49,7 @@ var Book = function(root, options, parent) {
this.files = [];
// List of plugins
- this.plugins = {};
+ this.plugins = [];
// Readme file
this.readmeFile = "README.md";
@@ -134,7 +135,7 @@ Book.prototype.generate = function(generator) {
if (!Generator) throw "Generator '"+that.options.generator+"' doesn't exist";
generator = new Generator(that);
- return generator.load();
+ return generator.prepare();
})
// Generate content
@@ -309,7 +310,25 @@ Book.prototype.parsePage = function(filename) {
return filetype.parser.page(content);
})
.then(function(page) {
+ // Type of parser used
+ page.type = filetype.name;
+
+ // Path relative to book
+ page.path = filename;
+
+ // Path absolute in the system
+ page.rawPath = path.resolve(that.root, filename);
+
+ // Progress in the book
page.progress = parseProgress(that.navigation, filename);
+
+ // Content sections
+ page.sections = pageUtil.normalize(page.sections, {
+ navigation: that.navigation,
+ base: path.dirname(filename) || './',
+ output: path.dirname(filename) || './'
+ });
+
return page;
});
};