summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/generate/json/index.js5
-rw-r--r--lib/generate/site/index.js7
-rw-r--r--lib/parse/page.js11
3 files changed, 14 insertions, 9 deletions
diff --git a/lib/generate/json/index.js b/lib/generate/json/index.js
index 6bc5211..a252ed3 100644
--- a/lib/generate/json/index.js
+++ b/lib/generate/json/index.js
@@ -29,8 +29,9 @@ Generator.prototype.convertFile = function(content, input) {
dir: path.dirname(input) || '/'
});
})
- .then(function(sections) {
- json.sections = sections;
+ .then(function(parsed) {
+ json.lexed = parsed.lexed;
+ json.sections = parsed.sections;
})
.then(function() {
return fs.writeFile(
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index 47d09f2..f0a4780 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -120,7 +120,7 @@ Generator.prototype.prepareFile = function(content, _input) {
.then(function() {
// Lex, parse includes and get
// Get HTML generated sections
- return parse.page(page, {
+ return parse.page(page.content, {
// Local files path
dir: path.dirname(_input) || '/',
@@ -134,8 +134,9 @@ Generator.prototype.prepareFile = function(content, _input) {
], path.join, fs.readFileSync)
});
})
- .then(function(sections) {
- page.sections = sections;
+ .then(function(parsed) {
+ page.lexed = parsed.lexed;
+ page.sections = parsed.sections;
// Use plugin hook
return _callHook("page");
diff --git a/lib/parse/page.js b/lib/parse/page.js
index 2cbbbf4..ca7441f 100644
--- a/lib/parse/page.js
+++ b/lib/parse/page.js
@@ -47,13 +47,14 @@ function quizQuestion(node) {
}
}
-function parsePage(page, options) {
+function parsePage(src, options) {
options = options || {};
// Lex if not already lexed
- page.lexed = (_.isArray(page.content) ? page.content : lex(include(page.content, options.includer || function() { return undefined; })))
- return page.lexed
- .map(function(section) {
+ var parsed = {
+ lexed: (_.isArray(src) ? page.content : lex(include(src, options.includer || function() { return undefined; })))
+ };
+ parsed.sections = parsed.lexed.map(function(section) {
// Transform given type
if(section.type === 'exercise') {
var nonCodeNodes = _.reject(section, {
@@ -151,6 +152,8 @@ function parsePage(page, options) {
content: render(section, options)
};
});
+
+ return parsed;
}
// Exports