lib/core/stream: LineIterator use CachedIterator
[nit.git] / lib / markdown2 / tests / test_commonmark_list_items.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 module test_commonmark_list_items is test
16
17 import test_markdown
18
19 class TestCommonmarkListItems
20 super TestMarkdownHtml
21 test
22
23 fun test216 is test do
24 var md = """A paragraph\nwith two lines.\n\n indented code\n\n> A block quote.\n"""
25 var html = """<p>A paragraph\nwith two lines.</p>\n<pre><code>indented code\n</code></pre>\n<blockquote>\n<p>A block quote.</p>\n</blockquote>\n"""
26 assert md_to_html(md) == html
27 end
28
29 fun test217 is test do
30 var md = """1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n"""
31 var html = """<ol>\n<li>\n<p>A paragraph\nwith two lines.</p>\n<pre><code>indented code\n</code></pre>\n<blockquote>\n<p>A block quote.</p>\n</blockquote>\n</li>\n</ol>\n"""
32 assert md_to_html(md) == html
33 end
34
35 fun test218 is test do
36 var md = """- one\n\n two\n"""
37 var html = """<ul>\n<li>one</li>\n</ul>\n<p>two</p>\n"""
38 assert md_to_html(md) == html
39 end
40
41 fun test219 is test do
42 var md = """- one\n\n two\n"""
43 var html = """<ul>\n<li>\n<p>one</p>\n<p>two</p>\n</li>\n</ul>\n"""
44 assert md_to_html(md) == html
45 end
46
47 fun test220 is test do
48 var md = """ - one\n\n two\n"""
49 var html = """<ul>\n<li>one</li>\n</ul>\n<pre><code> two\n</code></pre>\n"""
50 assert md_to_html(md) == html
51 end
52
53 fun test221 is test do
54 var md = """ - one\n\n two\n"""
55 var html = """<ul>\n<li>\n<p>one</p>\n<p>two</p>\n</li>\n</ul>\n"""
56 assert md_to_html(md) == html
57 end
58
59 fun test222 is test do
60 var md = """ > > 1. one\n>>\n>> two\n"""
61 var html = """<blockquote>\n<blockquote>\n<ol>\n<li>\n<p>one</p>\n<p>two</p>\n</li>\n</ol>\n</blockquote>\n</blockquote>\n"""
62 assert md_to_html(md) == html
63 end
64
65 fun test223 is test do
66 var md = """>>- one\n>>\n > > two\n"""
67 var html = """<blockquote>\n<blockquote>\n<ul>\n<li>one</li>\n</ul>\n<p>two</p>\n</blockquote>\n</blockquote>\n"""
68 assert md_to_html(md) == html
69 end
70
71 fun test224 is test do
72 var md = """-one\n\n2.two\n"""
73 var html = """<p>-one</p>\n<p>2.two</p>\n"""
74 assert md_to_html(md) == html
75 end
76
77 fun test225 is test do
78 var md = """- foo\n\n\n bar\n"""
79 var html = """<ul>\n<li>\n<p>foo</p>\n<p>bar</p>\n</li>\n</ul>\n"""
80 assert md_to_html(md) == html
81 end
82
83 fun test226 is test do
84 var md = """1. foo\n\n ```\n bar\n ```\n\n baz\n\n > bam\n"""
85 var html = """<ol>\n<li>\n<p>foo</p>\n<pre><code>bar\n</code></pre>\n<p>baz</p>\n<blockquote>\n<p>bam</p>\n</blockquote>\n</li>\n</ol>\n"""
86 assert md_to_html(md) == html
87 end
88
89 fun test227 is test do
90 var md = """- Foo\n\n bar\n\n\n baz\n"""
91 var html = """<ul>\n<li>\n<p>Foo</p>\n<pre><code>bar\n\n\nbaz\n</code></pre>\n</li>\n</ul>\n"""
92 assert md_to_html(md) == html
93 end
94
95 fun test228 is test do
96 var md = """123456789. ok\n"""
97 var html = """<ol start="123456789">\n<li>ok</li>\n</ol>\n"""
98 assert md_to_html(md) == html
99 end
100
101 fun test229 is test do
102 var md = """1234567890. not ok\n"""
103 var html = """<p>1234567890. not ok</p>\n"""
104 assert md_to_html(md) == html
105 end
106
107 fun test230 is test do
108 var md = """0. ok\n"""
109 var html = """<ol start="0">\n<li>ok</li>\n</ol>\n"""
110 assert md_to_html(md) == html
111 end
112
113 fun test231 is test do
114 var md = """003. ok\n"""
115 var html = """<ol start="3">\n<li>ok</li>\n</ol>\n"""
116 assert md_to_html(md) == html
117 end
118
119 fun test232 is test do
120 var md = """-1. not ok\n"""
121 var html = """<p>-1. not ok</p>\n"""
122 assert md_to_html(md) == html
123 end
124
125 fun test233 is test do
126 var md = """- foo\n\n bar\n"""
127 var html = """<ul>\n<li>\n<p>foo</p>\n<pre><code>bar\n</code></pre>\n</li>\n</ul>\n"""
128 assert md_to_html(md) == html
129 end
130
131 fun test234 is test do
132 var md = """ 10. foo\n\n bar\n"""
133 var html = """<ol start="10">\n<li>\n<p>foo</p>\n<pre><code>bar\n</code></pre>\n</li>\n</ol>\n"""
134 assert md_to_html(md) == html
135 end
136
137 fun test235 is test do
138 var md = """ indented code\n\nparagraph\n\n more code\n"""
139 var html = """<pre><code>indented code\n</code></pre>\n<p>paragraph</p>\n<pre><code>more code\n</code></pre>\n"""
140 assert md_to_html(md) == html
141 end
142
143 fun test236 is test do
144 var md = """1. indented code\n\n paragraph\n\n more code\n"""
145 var html = """<ol>\n<li>\n<pre><code>indented code\n</code></pre>\n<p>paragraph</p>\n<pre><code>more code\n</code></pre>\n</li>\n</ol>\n"""
146 assert md_to_html(md) == html
147 end
148
149 fun test237 is test do
150 var md = """1. indented code\n\n paragraph\n\n more code\n"""
151 var html = """<ol>\n<li>\n<pre><code> indented code\n</code></pre>\n<p>paragraph</p>\n<pre><code>more code\n</code></pre>\n</li>\n</ol>\n"""
152 assert md_to_html(md) == html
153 end
154
155 fun test238 is test do
156 var md = """ foo\n\nbar\n"""
157 var html = """<p>foo</p>\n<p>bar</p>\n"""
158 assert md_to_html(md) == html
159 end
160
161 fun test239 is test do
162 var md = """- foo\n\n bar\n"""
163 var html = """<ul>\n<li>foo</li>\n</ul>\n<p>bar</p>\n"""
164 assert md_to_html(md) == html
165 end
166
167 fun test240 is test do
168 var md = """- foo\n\n bar\n"""
169 var html = """<ul>\n<li>\n<p>foo</p>\n<p>bar</p>\n</li>\n</ul>\n"""
170 assert md_to_html(md) == html
171 end
172
173 fun test241 is test do
174 var md = """-\n foo\n-\n ```\n bar\n ```\n-\n baz\n"""
175 var html = """<ul>\n<li>foo</li>\n<li>\n<pre><code>bar\n</code></pre>\n</li>\n<li>\n<pre><code>baz\n</code></pre>\n</li>\n</ul>\n"""
176 assert md_to_html(md) == html
177 end
178
179 fun test242 is test do
180 var md = """- \n foo\n"""
181 var html = """<ul>\n<li>foo</li>\n</ul>\n"""
182 assert md_to_html(md) == html
183 end
184
185 fun test243 is test do
186 var md = """-\n\n foo\n"""
187 var html = """<ul>\n<li></li>\n</ul>\n<p>foo</p>\n"""
188 assert md_to_html(md) == html
189 end
190
191 fun test244 is test do
192 var md = """- foo\n-\n- bar\n"""
193 var html = """<ul>\n<li>foo</li>\n<li></li>\n<li>bar</li>\n</ul>\n"""
194 assert md_to_html(md) == html
195 end
196
197 fun test245 is test do
198 var md = """- foo\n- \n- bar\n"""
199 var html = """<ul>\n<li>foo</li>\n<li></li>\n<li>bar</li>\n</ul>\n"""
200 assert md_to_html(md) == html
201 end
202
203 fun test246 is test do
204 var md = """1. foo\n2.\n3. bar\n"""
205 var html = """<ol>\n<li>foo</li>\n<li></li>\n<li>bar</li>\n</ol>\n"""
206 assert md_to_html(md) == html
207 end
208
209 fun test247 is test do
210 var md = """*\n"""
211 var html = """<ul>\n<li></li>\n</ul>\n"""
212 assert md_to_html(md) == html
213 end
214
215 fun test248 is test do
216 var md = """foo\n*\n\nfoo\n1.\n"""
217 var html = """<p>foo\n*</p>\n<p>foo\n1.</p>\n"""
218 assert md_to_html(md) == html
219 end
220
221 fun test249 is test do
222 var md = """ 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n"""
223 var html = """<ol>\n<li>\n<p>A paragraph\nwith two lines.</p>\n<pre><code>indented code\n</code></pre>\n<blockquote>\n<p>A block quote.</p>\n</blockquote>\n</li>\n</ol>\n"""
224 assert md_to_html(md) == html
225 end
226
227 fun test250 is test do
228 var md = """ 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n"""
229 var html = """<ol>\n<li>\n<p>A paragraph\nwith two lines.</p>\n<pre><code>indented code\n</code></pre>\n<blockquote>\n<p>A block quote.</p>\n</blockquote>\n</li>\n</ol>\n"""
230 assert md_to_html(md) == html
231 end
232
233 fun test251 is test do
234 var md = """ 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n"""
235 var html = """<ol>\n<li>\n<p>A paragraph\nwith two lines.</p>\n<pre><code>indented code\n</code></pre>\n<blockquote>\n<p>A block quote.</p>\n</blockquote>\n</li>\n</ol>\n"""
236 assert md_to_html(md) == html
237 end
238
239 fun test252 is test do
240 var md = """ 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n"""
241 var html = """<pre><code>1. A paragraph\n with two lines.\n\n indented code\n\n &gt; A block quote.\n</code></pre>\n"""
242 assert md_to_html(md) == html
243 end
244
245 fun test253 is test do
246 var md = """ 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote.\n"""
247 var html = """<ol>\n<li>\n<p>A paragraph\nwith two lines.</p>\n<pre><code>indented code\n</code></pre>\n<blockquote>\n<p>A block quote.</p>\n</blockquote>\n</li>\n</ol>\n"""
248 assert md_to_html(md) == html
249 end
250
251 fun test254 is test do
252 var md = """ 1. A paragraph\n with two lines.\n"""
253 var html = """<ol>\n<li>A paragraph\nwith two lines.</li>\n</ol>\n"""
254 assert md_to_html(md) == html
255 end
256
257 fun test255 is test do
258 var md = """> 1. > Blockquote\ncontinued here.\n"""
259 var html = """<blockquote>\n<ol>\n<li>\n<blockquote>\n<p>Blockquote\ncontinued here.</p>\n</blockquote>\n</li>\n</ol>\n</blockquote>\n"""
260 assert md_to_html(md) == html
261 end
262
263 fun test256 is test do
264 var md = """> 1. > Blockquote\n> continued here.\n"""
265 var html = """<blockquote>\n<ol>\n<li>\n<blockquote>\n<p>Blockquote\ncontinued here.</p>\n</blockquote>\n</li>\n</ol>\n</blockquote>\n"""
266 assert md_to_html(md) == html
267 end
268
269 fun test257 is test do
270 var md = """- foo\n - bar\n - baz\n - boo\n"""
271 var html = """<ul>\n<li>foo\n<ul>\n<li>bar\n<ul>\n<li>baz\n<ul>\n<li>boo</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n"""
272 assert md_to_html(md) == html
273 end
274
275 fun test258 is test do
276 var md = """- foo\n - bar\n - baz\n - boo\n"""
277 var html = """<ul>\n<li>foo</li>\n<li>bar</li>\n<li>baz</li>\n<li>boo</li>\n</ul>\n"""
278 assert md_to_html(md) == html
279 end
280
281 fun test259 is test do
282 var md = """10) foo\n - bar\n"""
283 var html = """<ol start="10">\n<li>foo\n<ul>\n<li>bar</li>\n</ul>\n</li>\n</ol>\n"""
284 assert md_to_html(md) == html
285 end
286
287 fun test260 is test do
288 var md = """10) foo\n - bar\n"""
289 var html = """<ol start="10">\n<li>foo</li>\n</ol>\n<ul>\n<li>bar</li>\n</ul>\n"""
290 assert md_to_html(md) == html
291 end
292
293 fun test261 is test do
294 var md = """- - foo\n"""
295 var html = """<ul>\n<li>\n<ul>\n<li>foo</li>\n</ul>\n</li>\n</ul>\n"""
296 assert md_to_html(md) == html
297 end
298
299 fun test262 is test do
300 var md = """1. - 2. foo\n"""
301 var html = """<ol>\n<li>\n<ul>\n<li>\n<ol start="2">\n<li>foo</li>\n</ol>\n</li>\n</ul>\n</li>\n</ol>\n"""
302 assert md_to_html(md) == html
303 end
304
305 fun test263 is test do
306 var md = """- # Foo\n- Bar\n ---\n baz\n"""
307 var html = """<ul>\n<li>\n<h1>Foo</h1>\n</li>\n<li>\n<h2>Bar</h2>\nbaz</li>\n</ul>\n"""
308 assert md_to_html(md) == html
309 end
310 end