Use newfound ninja skills to refactor stuff

This commit is contained in:
Vit Brunner
2013-06-16 11:52:28 +01:00
parent 5a820848b8
commit 8bfbb29e9f
2 changed files with 8 additions and 14 deletions
@@ -9,15 +9,12 @@ angular.module("sideBySide").factory("jsonReader", () ->
return (source) ->
parsed = eval('(' + source + ')')
newContent = []
for verse in parsed.content
for i,verse of parsed.content
if typeof(verse) == "string"
newContent.push({ section: "", text: verse })
parsed.content[i] = { section: "", text: verse }
else
if "section" not of verse
verse.section = ""
newContent.push(verse)
verse.section = "" if "section" not of verse
parsed.content[i] = verse
parsed.content = newContent
return parsed
)
@@ -27,8 +27,7 @@ angular.module("sideBySide").factory("markdownReader", () ->
readSection = (lexed) ->
items = []
while lexed.length > 0
if lexed[0]["type"] == "heading"
break
break if lexed[0]["type"] == "heading"
items.push(lexed.shift())
return items
@@ -40,10 +39,9 @@ angular.module("sideBySide").factory("markdownReader", () ->
content = []
while lexed.length > 0
if lexed[0]["type"] == "heading"
heading = lexed.shift().text
else
heading = ''
heading = if lexed[0]["type"] == "heading" \
then lexed.shift().text \
else heading = ''
text = readSection(lexed)
text.links = lexed.links
@@ -51,7 +49,6 @@ angular.module("sideBySide").factory("markdownReader", () ->
section: heading
text: marked.parser(text)
})
return content
lexed = marked.lexer(source)