diff options
author | James Phillpotts <jphillpotts@scottlogic.co.uk> | 2014-04-08 09:51:11 +0100 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-04-12 01:25:07 -0700 |
commit | f6595f51119baca04bf91e619f64518d400e5cae (patch) | |
tree | 765ad8ab0f40d3bb68c03e8df1d5246664556e9c /lib/parse/lex.js | |
parent | ab27725b9935b185a58b725e75aedeb579e87d8f (diff) | |
download | gitbook-f6595f51119baca04bf91e619f64518d400e5cae.zip gitbook-f6595f51119baca04bf91e619f64518d400e5cae.tar.gz gitbook-f6595f51119baca04bf91e619f64518d400e5cae.tar.bz2 |
Tabular quiz
Diffstat (limited to 'lib/parse/lex.js')
-rw-r--r-- | lib/parse/lex.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/parse/lex.js b/lib/parse/lex.js index cec6047..b77b844 100644 --- a/lib/parse/lex.js +++ b/lib/parse/lex.js @@ -34,6 +34,22 @@ function sectionType(nodes, idx) { return 'exercise'; } + if (nodes.length > 2) { + var nonBlockquoteNodes = nodes.slice(nodes[0].type === 'paragraph' ? 1 : 0); + nonBlockquoteNodes.splice(_.findIndex(nonBlockquoteNodes, { type: 'blockquote_start' }), + _.findIndex(nonBlockquoteNodes, { type: 'blockquote_end' })); + + if (nonBlockquoteNodes.length === 2) { + if (_.every(nonBlockquoteNodes, { type: 'table' })) { + if (_.every(nonBlockquoteNodes[0].cells, function(row) { + return _.every(row.slice(1), function(cell) { return cell === "( )"; }); + })) { + return 'quiz'; + } + } + } + } + return 'normal'; } |