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_fenced_code_blocks
is test
19 class TestCommonmarkFencedCodeBlocks
20 super TestMarkdownHtml
24 var md
= """```\n<\n >\n```\n"""
25 var html
= """<pre><code><\n >\n</code></pre>\n"""
26 assert md_to_html
(md
) == html
30 var md
= """~~~\n<\n >\n~~~\n"""
31 var html
= """<pre><code><\n >\n</code></pre>\n"""
32 assert md_to_html
(md
) == html
36 var md
= """``\nfoo\n``\n"""
37 var html
= """<p><code>foo</code></p>\n"""
38 assert md_to_html
(md
) == html
42 var md
= """```\naaa\n~~~\n```\n"""
43 var html
= """<pre><code>aaa\n~~~\n</code></pre>\n"""
44 assert md_to_html
(md
) == html
48 var md
= """~~~\naaa\n```\n~~~\n"""
49 var html
= """<pre><code>aaa\n```\n</code></pre>\n"""
50 assert md_to_html
(md
) == html
54 var md
= """````\naaa\n```\n``````\n"""
55 var html
= """<pre><code>aaa\n```\n</code></pre>\n"""
56 assert md_to_html
(md
) == html
60 var md
= """~~~~\naaa\n~~~\n~~~~\n"""
61 var html
= """<pre><code>aaa\n~~~\n</code></pre>\n"""
62 assert md_to_html
(md
) == html
67 var html
= """<pre><code></code></pre>\n"""
68 assert md_to_html
(md
) == html
72 var md
= """`````\n\n```\naaa\n"""
73 var html
= """<pre><code>\n```\naaa\n</code></pre>\n"""
74 assert md_to_html
(md
) == html
78 var md
= """> ```\n> aaa\n\nbbb\n"""
79 var html
= """<blockquote>\n<pre><code>aaa\n</code></pre>\n</blockquote>\n<p>bbb</p>\n"""
80 assert md_to_html
(md
) == html
84 var md
= """```\n\n \n```\n"""
85 var html
= """<pre><code>\n \n</code></pre>\n"""
86 assert md_to_html
(md
) == html
90 var md
= """```\n```\n"""
91 var html
= """<pre><code></code></pre>\n"""
92 assert md_to_html
(md
) == html
95 fun test100
is test
do
96 var md
= """ ```\n aaa\naaa\n```\n"""
97 var html
= """<pre><code>aaa\naaa\n</code></pre>\n"""
98 assert md_to_html
(md
) == html
101 fun test101
is test
do
102 var md
= """ ```\naaa\n aaa\naaa\n ```\n"""
103 var html
= """<pre><code>aaa\naaa\naaa\n</code></pre>\n"""
104 assert md_to_html
(md
) == html
107 fun test102
is test
do
108 var md
= """ ```\n aaa\n aaa\n aaa\n ```\n"""
109 var html
= """<pre><code>aaa\n aaa\naaa\n</code></pre>\n"""
110 assert md_to_html
(md
) == html
113 fun test103
is test
do
114 var md
= """ ```\n aaa\n ```\n"""
115 var html
= """<pre><code>```\naaa\n```\n</code></pre>\n"""
116 assert md_to_html
(md
) == html
119 fun test104
is test
do
120 var md
= """```\naaa\n ```\n"""
121 var html
= """<pre><code>aaa\n</code></pre>\n"""
122 assert md_to_html
(md
) == html
125 fun test105
is test
do
126 var md
= """ ```\naaa\n ```\n"""
127 var html
= """<pre><code>aaa\n</code></pre>\n"""
128 assert md_to_html
(md
) == html
131 fun test106
is test
do
132 var md
= """```\naaa\n ```\n"""
133 var html
= """<pre><code>aaa\n ```\n</code></pre>\n"""
134 assert md_to_html
(md
) == html
137 fun test107
is test
do
138 var md
= """``` ```\naaa\n"""
139 var html
= """<p><code></code>\naaa</p>\n"""
140 assert md_to_html
(md
) == html
143 fun test108
is test
do
144 var md
= """~~~~~~\naaa\n~~~ ~~\n"""
145 var html
= """<pre><code>aaa\n~~~ ~~\n</code></pre>\n"""
146 assert md_to_html
(md
) == html
149 fun test109
is test
do
150 var md
= """foo\n```\nbar\n```\nbaz\n"""
151 var html
= """<p>foo</p>\n<pre><code>bar\n</code></pre>\n<p>baz</p>\n"""
152 assert md_to_html
(md
) == html
155 fun test110
is test
do
156 var md
= """foo\n---\n~~~\nbar\n~~~\n# baz\n"""
157 var html
= """<h2>foo</h2>\n<pre><code>bar\n</code></pre>\n<h1>baz</h1>\n"""
158 assert md_to_html
(md
) == html
161 fun test111
is test
do
162 var md
= """```ruby\ndef foo(x)\n return 3\nend\n```\n"""
163 var html
= """<pre><code class="language-ruby">def foo(x)\n return 3\nend\n</code></pre>\n"""
164 assert md_to_html
(md
) == html
167 fun test112
is test
do
168 var md
= """~~~~ ruby startline=3 $%@#$\ndef foo(x)\n return 3\nend\n~~~~~~~\n"""
169 var html
= """<pre><code class="language-ruby">def foo(x)\n return 3\nend\n</code></pre>\n"""
170 assert md_to_html
(md
) == html
173 fun test113
is test
do
174 var md
= """````;\n````\n"""
175 var html
= """<pre><code class="language-;"></code></pre>\n"""
176 assert md_to_html
(md
) == html
179 fun test114
is test
do
180 var md
= """``` aa ```\nfoo\n"""
181 var html
= """<p><code>aa</code>\nfoo</p>\n"""
182 assert md_to_html
(md
) == html
185 fun test115
is test
do
186 var md
= """```\n``` aaa\n```\n"""
187 var html
= """<pre><code>``` aaa\n</code></pre>\n"""
188 assert md_to_html
(md
) == html