From 9da10e2b25cb8ad919bb8563cfdc81d9e0612341 Mon Sep 17 00:00:00 2001 From: codepiano Date: Fri, 31 Oct 2014 18:00:09 +0800 Subject: [PATCH] bugfix,init page object's lexed attribute. the page object's attribute 'lexed' is not correctly inited.so when use page.lexed to generate the search index file,nothing will be indexed. --- lib/generate/site/index.js | 2 +- lib/parse/page.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index a62108b0a..8190381fb 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.content, { + return parse.page(page, { // Local files path dir: path.dirname(_input) || '/', // Project's include folder diff --git a/lib/parse/page.js b/lib/parse/page.js index e694f1c87..e4d9c467d 100644 --- a/lib/parse/page.js +++ b/lib/parse/page.js @@ -47,11 +47,12 @@ function quizQuestion(node) { } } -function parsePage(src, options) { +function parsePage(page, options) { options = options || {}; // Lex if not already lexed - return (_.isArray(src) ? src : lex(include(src, [options.dir, options.includes_dir], options.variables))) + page.lexed = (_.isArray(page.content) ? page.content : lex(include(page.content, [options.dir, options.includes_dir], options.variables))) + return page.lexed .map(function(section) { // Transform given type if(section.type === 'exercise') {