1 # This file is part of NIT ( http://www.nitlanguage.org ).
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 module test_commonmark_list_items
is test
19 class TestCommonmarkListItems
20 super TestMarkdownHtml
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
209 fun test247
is test
do
211 var html
= """<ul>\n<li></li>\n</ul>\n"""
212 assert md_to_html
(md
) == html
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
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
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
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
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 > A block quote.\n</code></pre>\n"""
242 assert md_to_html
(md
) == html
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
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
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
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
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
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
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
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
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
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
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