Initial project setup

Featuring:
- middleman setup
- dummy controller and index page
- markdown reader and its qunit tests
- travis integration
This commit is contained in:
Vit Brunner
2013-06-10 22:30:02 +01:00
commit b7c12f928b
16 changed files with 315 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
angular.module("sideBySide").factory("markdownReader", () ->
return (source) ->
read_meta = (block, inlineLexer) ->
meta = {}
lexed = inlineLexer.output(block.text)
for line in lexed.split("\n")
match = /([^:]*):(.*)/.exec(line)
meta[match[1].trim()] = match[2].trim()
return meta
read_content = (lexed) ->
get_section = (lexed) ->
items = []
while lexed.length > 0
if lexed[0]["type"] == "heading"
break
items.push(lexed.shift())
return items
content = []
while lexed.length > 0
if lexed[0]["type"] == "heading"
heading = lexed.shift().text
else
heading = ''
text = get_section(lexed)
text.links = lexed.links
content.push({
section: heading
text: marked.parser(text)
})
return content
lexed = marked.lexer(source)
meta = lexed.shift()
inlineLexer = new marked.InlineLexer(lexed.links)
return {
meta: read_meta(meta, inlineLexer)
content: read_content(lexed)
}
)