diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-07-10 17:59:34 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-07-10 17:59:34 -0700 |
commit | a9f473260cdbf7944a8d95c4292a93897f9210eb (patch) | |
tree | 83e78b9028850606722da6ec66c45e453ee28693 /lib/parse/page.js | |
parent | 520045441b9401fadfba2b1b03696bd15b60027d (diff) | |
parent | d16577e8bf2e404cbc2cabb78fc1bf6c8a36d3ea (diff) | |
download | gitbook-a9f473260cdbf7944a8d95c4292a93897f9210eb.zip gitbook-a9f473260cdbf7944a8d95c4292a93897f9210eb.tar.gz gitbook-a9f473260cdbf7944a8d95c4292a93897f9210eb.tar.bz2 |
Merge pull request #356 from GitbookIO/feature/includes
Support importing code snippets
Diffstat (limited to 'lib/parse/page.js')
-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, } |