mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-18 00:25:07 +00:00
d730a3aac6
Maybe have a sections folder in the future and one per type (quiz/exercise/normal) ?
18 lines
392 B
JavaScript
18 lines
392 B
JavaScript
var _ = require('lodash');
|
|
|
|
function isExercise(nodes) {
|
|
var codeType = { type: 'code' };
|
|
|
|
// Number of code nodes in section
|
|
var len = _.filter(nodes, codeType).length;
|
|
|
|
return (
|
|
// Got 3 or 4 code blocks
|
|
(len === 3 || len === 4) &&
|
|
// Ensure all nodes are at the end
|
|
_.all(_.last(nodes, len), codeType)
|
|
);
|
|
}
|
|
|
|
module.exports = isExercise;
|