diff options
author | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-07-10 17:30:12 +0200 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-07-10 17:30:12 +0200 |
commit | 15b4053d6beeeda7ff89bc947149d61a1a8c2d21 (patch) | |
tree | 74ee8b5d71a2e619ff829a3562a160bb3e03f011 /lib/parse | |
parent | 925a9b1388dbe0f3495ddfca228bfd8508ef54ef (diff) | |
download | gitbook-15b4053d6beeeda7ff89bc947149d61a1a8c2d21.zip gitbook-15b4053d6beeeda7ff89bc947149d61a1a8c2d21.tar.gz gitbook-15b4053d6beeeda7ff89bc947149d61a1a8c2d21.tar.bz2 |
Support code includes for exercises
Diffstat (limited to 'lib/parse')
-rw-r--r-- | lib/parse/page.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/parse/page.js b/lib/parse/page.js index 6cfd3ca..d714a15 100644 --- a/lib/parse/page.js +++ b/lib/parse/page.js @@ -5,6 +5,7 @@ var hljs = require('highlight.js'); var lex = require('./lex'); var renderer = require('./renderer'); +var codeInclude = require('./code_include'); var lnormalize = require('../utils/lang').normalize; @@ -74,15 +75,20 @@ 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), lang: lang, code: { - base: codeNodes[0].text, - solution: codeNodes[1].text, - validation: codeNodes[2].text, + base: ci(codeNodes[0].text), + solution: ci(codeNodes[1].text), + validation: ci(codeNodes[2].text), // Context is optional context: codeNodes[3] ? codeNodes[3].text : null, } |