diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-11-03 17:40:38 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-11-03 17:40:38 +0100 |
commit | dfd487692a948b9d16f1fbd75b6c4dd65d44c1cb (patch) | |
tree | 5f295d74c8b96b5fd9f595c8f22c143bcee62540 /lib/parse | |
parent | 195374eceeb5812df3c14ee5fdb88ed7f3310a2b (diff) | |
download | gitbook-dfd487692a948b9d16f1fbd75b6c4dd65d44c1cb.zip gitbook-dfd487692a948b9d16f1fbd75b6c4dd65d44c1cb.tar.gz gitbook-dfd487692a948b9d16f1fbd75b6c4dd65d44c1cb.tar.bz2 |
Adapt new page.parse api for tests
Diffstat (limited to 'lib/parse')
-rw-r--r-- | lib/parse/page.js | 11 |
1 files changed, 7 insertions, 4 deletions
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 |