mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-09 11:34:24 +08:00
From Middleman to DocPad
This commit is contained in:
@@ -1 +0,0 @@
|
||||
angular.module 'sideBySide', ['sideBySide.controllers']
|
||||
@@ -1,6 +0,0 @@
|
||||
angular.module("sideBySide.controllers", [])
|
||||
.controller "comparisonController", ($scope) ->
|
||||
$scope.verses = [
|
||||
{ section: 'first', versions: [ 'a', '1' ] }
|
||||
{ section: 'second', versions: [ 'b', '2' ] }
|
||||
]
|
||||
@@ -1,16 +0,0 @@
|
||||
angular.module("sideBySide").factory("jsonReader", () ->
|
||||
return (source) ->
|
||||
parsed = eval('(' + source + ')')
|
||||
|
||||
new_content = []
|
||||
for verse in parsed.content
|
||||
if typeof(verse) == "string"
|
||||
new_content.push({ section: "", text: verse })
|
||||
else
|
||||
if "section" not of verse
|
||||
verse.section = ""
|
||||
new_content.push(verse)
|
||||
|
||||
parsed.content = new_content
|
||||
return parsed
|
||||
)
|
||||
@@ -1,45 +0,0 @@
|
||||
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)
|
||||
}
|
||||
)
|
||||
@@ -1,6 +0,0 @@
|
||||
this.testReader = (name, testCases) ->
|
||||
injector = angular.injector(["ng", "sideBySide"])
|
||||
reader = injector.get(name)
|
||||
|
||||
for testCase in testCases
|
||||
deepEqual(reader(testCase.tested), testCase.expected)
|
||||
@@ -1,29 +0,0 @@
|
||||
test("jsonReader", () ->
|
||||
testCases = [{
|
||||
tested: """
|
||||
{
|
||||
meta: {
|
||||
Title: "Test leading text"
|
||||
},
|
||||
content: [
|
||||
"<p><strong>This</strong> is leading text.</p>",
|
||||
{ section: "I", text: "<p>First section.</p>" },
|
||||
{ section: "II", text: "<p>Second section.</p>" },
|
||||
{ text: "<p>Another section.</p>" },
|
||||
],
|
||||
}"""
|
||||
expected: {
|
||||
meta: {
|
||||
Title: "Test leading text"
|
||||
}
|
||||
content: [
|
||||
{ section: "", text: "<p><strong>This</strong> is leading text.</p>" }
|
||||
{ section: "I", text: "<p>First section.</p>" }
|
||||
{ section: "II", text: "<p>Second section.</p>" }
|
||||
{ section: "", text: "<p>Another section.</p>" }
|
||||
]
|
||||
}
|
||||
}]
|
||||
|
||||
testReader("jsonReader", testCases)
|
||||
)
|
||||
@@ -1,74 +0,0 @@
|
||||
test("markdownReader", () ->
|
||||
testCases = [{
|
||||
tested: """
|
||||
Title: Universal Declaration of Human Rights
|
||||
Author: John Peters Humphrey
|
||||
Date: 1948
|
||||
Source: http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights
|
||||
|
||||
## 1
|
||||
All human beings are born *free* and equal in dignity and rights...
|
||||
|
||||
## 2
|
||||
Everyone is entitled to all the rights and freedoms...
|
||||
|
||||
Furthermore, no distinction shall be made on the basis of...
|
||||
|
||||
## 11.1
|
||||
Everyone charged with a penal offence has the right to be presumed...
|
||||
|
||||
## 11.2
|
||||
No one shall be held guilty of any penal offence...
|
||||
|
||||
## 13
|
||||
Everyone is entitled to:
|
||||
|
||||
- sex
|
||||
- drugs
|
||||
- rock & roll
|
||||
"""
|
||||
expected: {
|
||||
meta: {
|
||||
Title: "Universal Declaration of Human Rights"
|
||||
Author: "John Peters Humphrey"
|
||||
Date: "1948"
|
||||
Source: '<a href="http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights">http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights</a>'
|
||||
}
|
||||
content: [
|
||||
{ section: "1", text: "<p>All human beings are born <em>free</em> and equal in dignity and rights...</p>\n" }
|
||||
{ section: "2", text: """<p>Everyone is entitled to all the rights and freedoms...</p>
|
||||
<p>Furthermore, no distinction shall be made on the basis of...</p>\n""" }
|
||||
{ section: "11.1", text: "<p>Everyone charged with a penal offence has the right to be presumed...</p>\n" }
|
||||
{ section: "11.2", text: "<p>No one shall be held guilty of any penal offence...</p>\n" }
|
||||
{ section: "13", text: """<p>Everyone is entitled to:</p>
|
||||
<ul>
|
||||
<li>sex</li>
|
||||
<li>drugs</li>
|
||||
<li>rock & roll</li>
|
||||
</ul>\n""" }
|
||||
]
|
||||
}
|
||||
}, {
|
||||
tested: """
|
||||
Title: Test leading text
|
||||
|
||||
**This** is leading text.
|
||||
# I
|
||||
First section.
|
||||
# II
|
||||
Second section.
|
||||
"""
|
||||
expected: {
|
||||
meta: {
|
||||
Title: "Test leading text"
|
||||
}
|
||||
content: [
|
||||
{ section: "", text: "<p><strong>This</strong> is leading text.</p>\n" }
|
||||
{ section: "I", text: "<p>First section.</p>\n" }
|
||||
{ section: "II", text: "<p>Second section.</p>\n" }
|
||||
]
|
||||
}
|
||||
}]
|
||||
|
||||
testReader("markdownReader", testCases)
|
||||
)
|
||||
Reference in New Issue
Block a user