forked from devinus/markdown
-
Notifications
You must be signed in to change notification settings - Fork 1
/
markdown_test.exs
164 lines (111 loc) · 3.87 KB
/
markdown_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
defmodule MarkdownTest do
use ExUnit.Case
doctest Markdown
describe "to_html/2" do
test "with autolink: true" do
markdown = "http://devintorr.es/"
html = Markdown.to_html(markdown, autolink: true)
assert html =~ ~r[<a href="http://devintorr.es/">]
end
test "with disable_indented_code: true" do
markdown = """
1 + 1
"""
html = Markdown.to_html(markdown, disable_indented_code: true)
assert html == "<p>1 + 1</p>\n"
end
test "with escape: true" do
markdown = "<p>This is HTML</p>"
html = Markdown.to_html(markdown, escape: true)
assert html == "<p><p>This is HTML</p></p>\n"
end
test "with fenced_code: true" do
markdown = """
```
Markdown.to_html(markdown)
```
"""
html = Markdown.to_html(markdown, fenced_code: true)
assert html =~ ~r/<code>/
end
test "with hard_wrap: true" do
markdown = """
This has
line breaks
"""
html = Markdown.to_html(markdown, hard_wrap: true)
assert html == "<p>This has<br>\nline breaks</p>\n"
end
test "with highlight: true" do
markdown = "==mark==down"
html = Markdown.to_html(markdown, highlight: true)
assert html == "<p><mark>mark</mark>down</p>\n"
end
test "with math: true" do
markdown = "Einstein says $$e = mc^{2}$$"
html = Markdown.to_html(markdown, math: true)
assert html == "<p>Einstein says \\(e = mc^{2}\\)</p>\n"
end
test "with math_explicit: true" do
markdown = "Einstein says $$e = mc^{2}$$, not $e = mc$"
html = Markdown.to_html(markdown, math: true, math_explicit: true)
assert html == "<p>Einstein says \\[e = mc^{2}\\], not \\(e = mc\\)</p>\n"
end
test "with no_intra_emphasis: true" do
markdown = "This is _very_ im_pre_ssive"
html = Markdown.to_html(markdown, no_intra_emphasis: true)
assert html == "<p>This is <em>very</em> im_pre_ssive</p>\n"
end
test "with quote: true" do
markdown = ~s(This will be "quoted")
html = Markdown.to_html(markdown, quote: true)
assert html == "<p>This will be <q>quoted</q></p>\n"
end
test "with skip_html: true" do
markdown = "These tags will be <span>stripped</span>"
html = Markdown.to_html(markdown, skip_html: true)
assert html == "<p>These tags will be stripped</p>\n"
end
test "with space_headers: true" do
markdown = "#This is not a header"
html = Markdown.to_html(markdown, space_headers: true)
assert html == "<p>#This is not a header</p>\n"
end
test "with strikethrough: true" do
markdown = "Strike ~~One~~ ~~Two~~ Three"
html = Markdown.to_html(markdown, strikethrough: true)
assert html == "<p>Strike <del>One</del> <del>Two</del> Three</p>\n"
end
test "with superscript: true" do
markdown = "Here ^we^^go"
html = Markdown.to_html(markdown, superscript: true)
assert html == "<p>Here <sup>we<sup><sup>go</sup></sup></sup></p>\n"
end
test "with tables: true" do
markdown = """
| J | O |
| --- | --- |
| S | É |
"""
html = Markdown.to_html(markdown, tables: true)
assert html =~ ~r/<table>/
end
test "with underline: true" do
markdown = "This is not emphasis, this is _underline_"
html = Markdown.to_html(markdown, underline: true)
assert html == "<p>This is not emphasis, this is <u>underline</u></p>\n"
end
test "with use_xhtml: true" do
markdown = """
This is XHTML because of the self closing
![img tag](#img-tag)
"""
html = Markdown.to_html(markdown, use_xhtml: true)
expected_html = """
<p>This is XHTML because of the self closing
<img src="#img-tag" alt="img tag"/></p>
"""
assert html == expected_html
end
end
end