Created
April 10, 2018 15:52
-
-
Save jxe/cebe1154c1ee2ff691332b3a3b3ba773 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let text = ` | |
# a taster of HSC 1 | |
For 3-4 readers | |
This is a wild read that requires some intimacy with strangers. You'll be anonymous. | |
---- page ---- | |
Let's start out with a game about our values. | |
---- form ---- | |
Use this chart to fill in the blanks. | |
<Form> | |
</Form> | |
---- chat ---- | |
Now share some of the words you came up with, others will guess which category they came from. | |
---- page ---- | |
Let's see what else we can learn. Sometimes we are mixed up with values and norms. | |
` | |
function parse(text){ | |
let [intro, ...sections] = text.split(/^----\s*/m) | |
let title = (intro.match(/^# (.*)$/m)||[])[1] | |
let readers = (intro.match(/for ([\d-]*) readers/i)||[])[1] | |
sections = sections.map(s => { | |
let [header, contents] = s.split(/\s*----\n/) | |
let [type, params] = header.split(/\s+/, 2) | |
return {type, params, contents} | |
}) | |
return {intro, title, readers, sections} | |
} | |
console.log(parse(text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment