mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-10 12:37:06 +08:00
Use newfound ninja skills to refactor stuff
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user