summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/parse/lex.js5
-rw-r--r--lib/parse/page.js2
-rw-r--r--lib/parse/renderer.js4
3 files changed, 8 insertions, 3 deletions
diff --git a/lib/parse/lex.js b/lib/parse/lex.js
index 6b3236e..def74b4 100644
--- a/lib/parse/lex.js
+++ b/lib/parse/lex.js
@@ -23,7 +23,10 @@ function sectionType(nodes, idx) {
type: 'code'
}).length;
- if(codeNodes === 3 && (idx % 2) == 1) {
+ if(
+ (codeNodes === 3 || codeNodes === 4) &&
+ (idx % 2) === 1)
+ {
return 'exercise';
}
diff --git a/lib/parse/page.js b/lib/parse/page.js
index 56a9e60..3479c85 100644
--- a/lib/parse/page.js
+++ b/lib/parse/page.js
@@ -72,6 +72,8 @@ function parsePage(src, options) {
base: codeNodes[0].text,
solution: codeNodes[1].text,
validation: codeNodes[2].text,
+ // Context is optional
+ context: codeNodes[3] ? codeNodes[3].text : null,
}
};
}
diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js
index 848f6e3..86576f0 100644
--- a/lib/parse/renderer.js
+++ b/lib/parse/renderer.js
@@ -45,7 +45,7 @@ GitBookRenderer.prototype.link = function(href, title, text) {
var o = this._extra_options;
// Relative link, rewrite it to point to github repo
- if(!parsed.protocol && parsed.path[0] != '/' && o && o.repo && o.dir) {
+ if(!parsed.protocol && parsed.path && parsed.path[0] != '/' && o && o.repo && o.dir) {
href = 'https://github.com/' + o.repo + '/blob' + path.normalize(path.join(
'/',
o.dir,
@@ -79,7 +79,7 @@ GitBookRenderer.prototype.image = function(href, title, text) {
var o = this._extra_options;
// Relative image, rewrite it depending output
- if(!parsed.protocol && parsed.path[0] != '/' && o && o.dir && o.outdir) {
+ if(!parsed.protocol && parsed.path && parsed.path[0] != '/' && o && o.dir && o.outdir) {
_href = path.relative(o.outdir, path.normalize(path.join(
o.dir,
href