diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2014-10-15 21:29:23 +0200 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@gmail.com> | 2014-10-15 21:29:23 +0200 |
commit | ce50b893e926fed8905419efc8bce4a64ab2d5dc (patch) | |
tree | 83cf19e47f26fd77072ac63aeaf2152a4b30ffa6 /lib/parse/page.js | |
parent | 49e3bbc3d6e9e128df721494e9a10eaf15b7ddc8 (diff) | |
parent | 225ff27dd15b904d6a4a784c219522a28f316a5b (diff) | |
download | gitbook-ce50b893e926fed8905419efc8bce4a64ab2d5dc.zip gitbook-ce50b893e926fed8905419efc8bce4a64ab2d5dc.tar.gz gitbook-ce50b893e926fed8905419efc8bce4a64ab2d5dc.tar.bz2 |
Merge pull request #482 from GitbookIO/feature/includes
Add include support, with variables and the whole shebang
Diffstat (limited to 'lib/parse/page.js')
-rw-r--r-- | lib/parse/page.js | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/parse/page.js b/lib/parse/page.js index ae71666..e694f1c 100644 --- a/lib/parse/page.js +++ b/lib/parse/page.js @@ -5,7 +5,7 @@ var hljs = require('highlight.js'); var lex = require('./lex'); var renderer = require('./renderer'); -var codeInclude = require('./code_include'); +var include = require('./include'); var lnormalize = require('../utils/lang').normalize; @@ -51,7 +51,7 @@ function parsePage(src, options) { options = options || {}; // Lex if not already lexed - return (_.isArray(src) ? src : lex(src)) + return (_.isArray(src) ? src : lex(include(src, [options.dir, options.includes_dir], options.variables))) .map(function(section) { // Transform given type if(section.type === 'exercise') { @@ -74,20 +74,15 @@ function parsePage(src, options) { // Main language var lang = validLangs ? langs[0] : null; - // codeInclude shortcut - var ci = function(code) { - return codeInclude(code, options.dir); - }; - return { id: section.id, type: section.type, content: render(nonCodeNodes, options), lang: lang, code: { - base: ci(codeNodes[0].text), - solution: ci(codeNodes[1].text), - validation: ci(codeNodes[2].text), + base: codeNodes[0].text, + solution: codeNodes[1].text, + validation: codeNodes[2].text, // Context is optional context: codeNodes[3] ? codeNodes[3].text : null, } |