-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
17 changed files
with
267 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/docker | ||
/testdata | ||
.idea/ | ||
/mark.test |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mark | ||
|
||
import ( | ||
"io/ioutil" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/kovetskiy/mark/pkg/mark/stdlib" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
const ( | ||
NL = "\n" | ||
) | ||
|
||
func text(lines ...string) string { | ||
return strings.Join(lines, "\n") | ||
} | ||
|
||
func TestCompileMarkdown(t *testing.T) { | ||
test := assert.New(t) | ||
|
||
testcases, err := filepath.Glob("testdata/*.md") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for _, filename := range testcases { | ||
basename := filepath.Base(filename) | ||
testname := strings.TrimSuffix(basename, ".md") | ||
htmlname := filepath.Join(filepath.Dir(filename), testname+".html") | ||
|
||
markdown, err := ioutil.ReadFile(filename) | ||
if err != nil { | ||
panic(err) | ||
} | ||
html, err := ioutil.ReadFile(htmlname) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
lib, err := stdlib.New(nil) | ||
if err != nil { | ||
panic(err) | ||
} | ||
actual := CompileMarkdown(markdown, lib) | ||
test.EqualValues(string(html), actual, filename+" vs "+htmlname) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<p><code>inline</code></p> | ||
<ac:structured-macro ac:name="expand"> | ||
<ac:parameter ac:name="title"></ac:parameter> | ||
<ac:rich-text-body> | ||
<ac:structured-macro ac:name="code"> | ||
<ac:parameter ac:name="language"></ac:parameter> | ||
<ac:parameter ac:name="collapse">false</ac:parameter> | ||
<ac:parameter ac:name="title"></ac:parameter> | ||
<ac:plain-text-body><![CDATA[some code | ||
]]></ac:plain-text-body> | ||
</ac:structured-macro> | ||
</ac:rich-text-body> | ||
</ac:structured-macro> | ||
<ac:structured-macro ac:name="expand"> | ||
<ac:parameter ac:name="title"></ac:parameter> | ||
<ac:rich-text-body> | ||
<ac:structured-macro ac:name="code"> | ||
<ac:parameter ac:name="language">bash</ac:parameter> | ||
<ac:parameter ac:name="collapse">false</ac:parameter> | ||
<ac:parameter ac:name="title"></ac:parameter> | ||
<ac:plain-text-body><![CDATA[code bash | ||
]]></ac:plain-text-body> | ||
</ac:structured-macro> | ||
</ac:rich-text-body> | ||
</ac:structured-macro> | ||
<ac:structured-macro ac:name="expand"> | ||
<ac:parameter ac:name="title"></ac:parameter> | ||
<ac:rich-text-body> | ||
<ac:structured-macro ac:name="code"> | ||
<ac:parameter ac:name="language">unknown</ac:parameter> | ||
<ac:parameter ac:name="collapse">false</ac:parameter> | ||
<ac:parameter ac:name="title"></ac:parameter> | ||
<ac:plain-text-body><![CDATA[unknown code | ||
]]></ac:plain-text-body> | ||
</ac:structured-macro> | ||
</ac:rich-text-body> | ||
</ac:structured-macro> | ||
|
||
<p>text<br /> | ||
text 2</p> | ||
<ac:structured-macro ac:name="expand"> | ||
<ac:parameter ac:name="title"></ac:parameter> | ||
<ac:rich-text-body> | ||
<ac:structured-macro ac:name="code"> | ||
<ac:parameter ac:name="language">unknown</ac:parameter> | ||
<ac:parameter ac:name="collapse">false</ac:parameter> | ||
<ac:parameter ac:name="title"></ac:parameter> | ||
<ac:plain-text-body><![CDATA[unknown code 2 | ||
]]></ac:plain-text-body> | ||
</ac:structured-macro> | ||
</ac:rich-text-body> | ||
</ac:structured-macro> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
`inline` | ||
|
||
``` | ||
some code | ||
``` | ||
```bash | ||
code bash | ||
``` | ||
|
||
```unknown | ||
unknown code | ||
``` | ||
text | ||
text 2 | ||
```unknown | ||
unknown code 2 | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<h1 id="a">a</h1> | ||
|
||
<h2 id="b">b</h2> | ||
|
||
<h3 id="c">c</h3> | ||
|
||
<h4 id="d">d</h4> | ||
|
||
<h5 id="e">e</h5> | ||
|
||
<h1 id="f">f</h1> | ||
|
||
<h2 id="g">g</h2> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# a | ||
## b | ||
### c | ||
#### d | ||
##### e | ||
f | ||
= | ||
g | ||
- |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<ul> | ||
<li>dash 1-1<br /></li> | ||
<li>dash 1-2<br /></li> | ||
<li>dash 1-3<br /> | ||
|
||
<ul> | ||
<li>dash 1-3-1<br /></li> | ||
<li>dash 1-3-2<br /></li> | ||
<li>dash 1-3-3<br /> | ||
|
||
<ul> | ||
<li>dash 1-3-3-1<br /> | ||
<br /></li> | ||
</ul></li> | ||
</ul></li> | ||
</ul> | ||
|
||
<p>text</p> | ||
|
||
<ul> | ||
<li>a<br /></li> | ||
<li>b<br /></li> | ||
<li>c<br /></li> | ||
</ul> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- dash 1-1 | ||
- dash 1-2 | ||
- dash 1-3 | ||
- dash 1-3-1 | ||
- dash 1-3-2 | ||
- dash 1-3-3 | ||
- dash 1-3-3-1 | ||
|
||
text | ||
|
||
* a | ||
* b | ||
* c |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<p>one-1<br /> | ||
one-2</p> | ||
|
||
<p>two-1</p> | ||
|
||
<p>two-2</p> | ||
|
||
<p>three-1</p> | ||
|
||
<p>three-2</p> | ||
|
||
<p>space-1<br /> | ||
space-2</p> | ||
|
||
<p>2space-1<br /> | ||
2space-2</p> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
one-1 | ||
one-2 | ||
|
||
two-1 | ||
|
||
two-2 | ||
|
||
three-1 | ||
|
||
|
||
three-2 | ||
|
||
space-1 | ||
space-2 | ||
|
||
2space-1 | ||
2space-2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p><b>bold</b><br /> | ||
<strong>bold</strong></p> | ||
|
||
<p><i>vitalik</i><br /> | ||
<em>vitalik</em></p> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<b>bold</b> | ||
**bold** | ||
|
||
<i>vitalik</i> | ||
*vitalik* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!-- Space: MARKTEST --> | ||
<!-- Parent: Parent1 --> | ||
<!-- Parent: Parent2 --> | ||
<!-- Parent: Parent3 --> | ||
<!-- Parent: Parent4 --> | ||
<!-- Parent: Parent5 --> | ||
<!-- Parent: Parent6 --> | ||
<!-- Title: Test Page --> | ||
|
||
a | ||
b | ||
|
||
- a | ||
- b |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- Space: MARKTEST --> | ||
<!-- Parent: mark --> | ||
<!-- Title: Bob --> | ||
|
||
Alice: [alice](alice.md) |