summaryrefslogtreecommitdiffstats
path: root/lib/page.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/page.js')
-rw-r--r--lib/page.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/page.js b/lib/page.js
index 3eabb09..1929f6b 100644
--- a/lib/page.js
+++ b/lib/page.js
@@ -18,10 +18,26 @@ function splitSections(nodes) {
}, []).concat([section]); // Add remaining nodes
}
+// What is the type of this section
+function sectionType(nodes) {
+ if(_.filter(nodes, {
+ type: 'code'
+ }).length === 3) {
+ return 'exercise';
+ }
+
+ return 'normal';
+}
+
function parsePage(src) {
var nodes = marked.lexer(src);
- return splitSections(nodes);
+ return _.chain(splitSections(nodes))
+ .map(function(section) {
+ section.type = sectionType(section);
+ return section;
+ })
+ .value();
}
// Exports