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_html_blocks
is test
19 class TestCommonmarkHTMLBlocks
20 super TestMarkdownHtml
23 fun test116
is test
do
24 var md
= """<table><tr><td>\n<pre>\n**Hello**,\n\n_world_.\n</pre>\n</td></tr></table>\n"""
25 var html
= """<table><tr><td>\n<pre>\n**Hello**,\n<p><em>world</em>.\n</pre></p>\n</td></tr></table>\n"""
26 assert md_to_html
(md
) == html
29 fun test117
is test
do
30 var md
= """<table>\n <tr>\n <td>\n hi\n </td>\n </tr>\n</table>\n\nokay.\n"""
31 var html
= """<table>\n <tr>\n <td>\n hi\n </td>\n </tr>\n</table>\n<p>okay.</p>\n"""
32 assert md_to_html
(md
) == html
35 fun test118
is test
do
36 var md
= """ <div>\n *hello*\n <foo><a>\n"""
37 var html
= """ <div>\n *hello*\n <foo><a>\n"""
38 assert md_to_html
(md
) == html
41 fun test119
is test
do
42 var md
= """</div>\n*foo*\n"""
43 var html
= """</div>\n*foo*\n"""
44 assert md_to_html
(md
) == html
47 fun test120
is test
do
48 var md
= """<DIV CLASS="foo">\n\n*Markdown*\n\n</DIV>\n"""
49 var html
= """<DIV CLASS="foo">\n<p><em>Markdown</em></p>\n</DIV>\n"""
50 assert md_to_html
(md
) == html
53 fun test121
is test
do
54 var md
= """<div id="foo"\n class="bar">\n</div>\n"""
55 var html
= """<div id="foo"\n class="bar">\n</div>\n"""
56 assert md_to_html
(md
) == html
59 fun test122
is test
do
60 var md
= """<div id="foo" class="bar\n baz">\n</div>\n"""
61 var html
= """<div id="foo" class="bar\n baz">\n</div>\n"""
62 assert md_to_html
(md
) == html
65 fun test123
is test
do
66 var md
= """<div>\n*foo*\n\n*bar*\n"""
67 var html
= """<div>\n*foo*\n<p><em>bar</em></p>\n"""
68 assert md_to_html
(md
) == html
71 fun test124
is test
do
72 var md
= """<div id="foo"\n*hi*\n"""
73 var html
= """<div id="foo"\n*hi*\n"""
74 assert md_to_html
(md
) == html
77 fun test125
is test
do
78 var md
= """<div class\nfoo\n"""
79 var html
= """<div class\nfoo\n"""
80 assert md_to_html
(md
) == html
83 fun test126
is test
do
84 var md
= """<div *???-&&&-<---\n*foo*\n"""
85 var html
= """<div *???-&&&-<---\n*foo*\n"""
86 assert md_to_html
(md
) == html
89 fun test127
is test
do
90 var md
= """<div><a href="bar">*foo*</a></div>\n"""
91 var html
= """<div><a href="bar">*foo*</a></div>\n"""
92 assert md_to_html
(md
) == html
95 fun test128
is test
do
96 var md
= """<table><tr><td>\nfoo\n</td></tr></table>\n"""
97 var html
= """<table><tr><td>\nfoo\n</td></tr></table>\n"""
98 assert md_to_html
(md
) == html
101 fun test129
is test
do
102 var md
= """<div></div>\n``` c\nint x = 33;\n```\n"""
103 var html
= """<div></div>\n``` c\nint x = 33;\n```\n"""
104 assert md_to_html
(md
) == html
107 fun test130
is test
do
108 var md
= """<a href="foo">\n*bar*\n</a>\n"""
109 var html
= """<a href="foo">\n*bar*\n</a>\n"""
110 assert md_to_html
(md
) == html
113 fun test131
is test
do
114 var md
= """<Warning>\n*bar*\n</Warning>\n"""
115 var html
= """<Warning>\n*bar*\n</Warning>\n"""
116 assert md_to_html
(md
) == html
119 fun test132
is test
do
120 var md
= """<i class="foo">\n*bar*\n</i>\n"""
121 var html
= """<i class="foo">\n*bar*\n</i>\n"""
122 assert md_to_html
(md
) == html
125 fun test133
is test
do
126 var md
= """</ins>\n*bar*\n"""
127 var html
= """</ins>\n*bar*\n"""
128 assert md_to_html
(md
) == html
131 fun test134
is test
do
132 var md
= """<del>\n*foo*\n</del>\n"""
133 var html
= """<del>\n*foo*\n</del>\n"""
134 assert md_to_html
(md
) == html
137 fun test135
is test
do
138 var md
= """<del>\n\n*foo*\n\n</del>\n"""
139 var html
= """<del>\n<p><em>foo</em></p>\n</del>\n"""
140 assert md_to_html
(md
) == html
143 fun test136
is test
do
144 var md
= """<del>*foo*</del>\n"""
145 var html
= """<p><del><em>foo</em></del></p>\n"""
146 assert md_to_html
(md
) == html
149 fun test137
is test
do
150 var md
= """<pre language="haskell"><code>\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n</code></pre>\nokay\n"""
151 var html
= """<pre language="haskell"><code>\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n</code></pre>\n<p>okay</p>\n"""
152 assert md_to_html
(md
) == html
155 fun test138
is test
do
156 var md
= """<script type="text/javascript">\n// JavaScript example\n\ndocument.getElementById("demo").innerHTML = "Hello JavaScript!";\n</script>\nokay\n"""
157 var html
= """<script type="text/javascript">\n// JavaScript example\n\ndocument.getElementById("demo").innerHTML = "Hello JavaScript!";\n</script>\n<p>okay</p>\n"""
158 assert md_to_html
(md
) == html
161 fun test139
is test
do
162 var md
= """<style\n type="text/css">\nh1 {color:red;}\n\np {color:blue;}\n</style>\nokay\n"""
163 var html
= """<style\n type="text/css">\nh1 {color:red;}\n\np {color:blue;}\n</style>\n<p>okay</p>\n"""
164 assert md_to_html
(md
) == html
167 fun test140
is test
do
168 var md
= """<style\n type="text/css">\n\nfoo\n"""
169 var html
= """<style\n type="text/css">\n\nfoo\n"""
170 assert md_to_html
(md
) == html
173 fun test141
is test
do
174 var md
= """> <div>\n> foo\n\nbar\n"""
175 var html
= """<blockquote>\n<div>\nfoo\n</blockquote>\n<p>bar</p>\n"""
176 assert md_to_html
(md
) == html
179 fun test142
is test
do
180 var md
= """- <div>\n- foo\n"""
181 var html
= """<ul>\n<li>\n<div>\n</li>\n<li>foo</li>\n</ul>\n"""
182 assert md_to_html
(md
) == html
185 fun test143
is test
do
186 var md
= """<style>p{color:red;}</style>\n*foo*\n"""
187 var html
= """<style>p{color:red;}</style>\n<p><em>foo</em></p>\n"""
188 assert md_to_html
(md
) == html
191 fun test144
is test
do
192 var md
= """<!-- foo -->*bar*\n*baz*\n"""
193 var html
= """<!-- foo -->*bar*\n<p><em>baz</em></p>\n"""
194 assert md_to_html
(md
) == html
197 fun test145
is test
do
198 var md
= """<script>\nfoo\n</script>1. *bar*\n"""
199 var html
= """<script>\nfoo\n</script>1. *bar*\n"""
200 assert md_to_html
(md
) == html
203 fun test146
is test
do
204 var md
= """<!-- Foo\n\nbar\n baz -->\nokay\n"""
205 var html
= """<!-- Foo\n\nbar\n baz -->\n<p>okay</p>\n"""
206 assert md_to_html
(md
) == html
209 fun test147
is test
do
210 var md
= """<?php\n\n echo '>';\n\n?>\nokay\n"""
211 var html
= """<?php\n\n echo '>';\n\n?>\n<p>okay</p>\n"""
212 assert md_to_html
(md
) == html
215 fun test148
is test
do
216 var md
= """<!DOCTYPE html>\n"""
217 var html
= """<!DOCTYPE html>\n"""
218 assert md_to_html
(md
) == html
221 fun test149
is test
do
222 var md
= """<![CDATA[\nfunction matchwo(a,b)\n{\n if (a < b && a < 0) then {\n return 1;\n\n } else {\n\n return 0;\n }\n}\n]]>\nokay\n"""
223 var html
= """<![CDATA[\nfunction matchwo(a,b)\n{\n if (a < b && a < 0) then {\n return 1;\n\n } else {\n\n return 0;\n }\n}\n]]>\n<p>okay</p>\n"""
224 assert md_to_html
(md
) == html
227 fun test150
is test
do
228 var md
= """ <!-- foo -->\n\n <!-- foo -->\n"""
229 var html
= """ <!-- foo -->\n<pre><code><!-- foo -->\n</code></pre>\n"""
230 assert md_to_html
(md
) == html
233 fun test151
is test
do
234 var md
= """ <div>\n\n <div>\n"""
235 var html
= """ <div>\n<pre><code><div>\n</code></pre>\n"""
236 assert md_to_html
(md
) == html
239 fun test152
is test
do
240 var md
= """Foo\n<div>\nbar\n</div>\n"""
241 var html
= """<p>Foo</p>\n<div>\nbar\n</div>\n"""
242 assert md_to_html
(md
) == html
245 fun test153
is test
do
246 var md
= """<div>\nbar\n</div>\n*foo*\n"""
247 var html
= """<div>\nbar\n</div>\n*foo*\n"""
248 assert md_to_html
(md
) == html
251 fun test154
is test
do
252 var md
= """Foo\n<a href="bar">\nbaz\n"""
253 var html
= """<p>Foo\n<a href="bar">\nbaz</p>\n"""
254 assert md_to_html
(md
) == html
257 fun test155
is test
do
258 var md
= """<div>\n\n*Emphasized* text.\n\n</div>\n"""
259 var html
= """<div>\n<p><em>Emphasized</em> text.</p>\n</div>\n"""
260 assert md_to_html
(md
) == html
263 fun test156
is test
do
264 var md
= """<div>\n*Emphasized* text.\n</div>\n"""
265 var html
= """<div>\n*Emphasized* text.\n</div>\n"""
266 assert md_to_html
(md
) == html
269 fun test157
is test
do
270 var md
= """<table>\n\n<tr>\n\n<td>\nHi\n</td>\n\n</tr>\n\n</table>\n"""
271 var html
= """<table>\n<tr>\n<td>\nHi\n</td>\n</tr>\n</table>\n"""
272 assert md_to_html
(md
) == html
275 fun test158
is test
do
276 var md
= """<table>\n\n <tr>\n\n <td>\n Hi\n </td>\n\n </tr>\n\n</table>\n"""
277 var html
= """<table>\n <tr>\n<pre><code><td>\n Hi\n</td>\n</code></pre>\n </tr>\n</table>\n"""
278 assert md_to_html
(md
) == html