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 # Tests for markdown Github mode
16 module test_markdown_github
is test
19 import test_markdown_location
20 import test_markdown_md
21 import test_markdown_man
22 import test_markdown_latex
24 redef class TestMarkdown
25 redef var md_parser
is lazy
do
27 parser
.github_mode
= true
32 class TestGithubLocation
33 super TestMarkdownLocation
36 fun test_github_strike
is test
do
42 MdParagraph: 1,1--1,17
48 assert md_to_loc
(md
) == loc
51 fun test_github_strike2
is test
do
57 MdParagraph: 1,1--1,19
63 assert md_to_loc
(md
) == loc
66 fun test_github_super
is test
do
72 MdParagraph: 1,1--1,17
78 assert md_to_loc
(md
) == loc
81 fun test_github_super2
is test
do
87 MdParagraph: 1,1--1,19
93 assert md_to_loc
(md
) == loc
98 super TestMarkdownHtml
101 fun test_strike1
is test
do
102 var md
= """foo ~bar~ baz\n"""
103 var html
= """<p>foo <del>bar</del> baz</p>\n"""
104 assert md_to_html
(md
) == html
107 fun test_strike2
is test
do
108 var md
= """foo ~~bar~~ baz\n"""
109 var html
= """<p>foo <del>bar</del> baz</p>\n"""
110 assert md_to_html
(md
) == html
113 fun test_strike3
is test
do
114 var md
= """foo ~~~bar~~~ baz\n"""
115 var html
= """<p>foo <del>bar</del> baz</p>\n"""
116 assert md_to_html
(md
) == html
119 fun test_strike4
is test
do
120 var md
= """foo ~~~~bar~~~~ baz\n"""
121 var html
= """<p>foo <del>bar</del> baz</p>\n"""
122 assert md_to_html
(md
) == html
125 fun test_strike5
is test
do
126 var md
= """foo ~~~~~bar~~~~~ baz\n"""
127 var html
= """<p>foo <del>bar</del> baz</p>\n"""
128 assert md_to_html
(md
) == html
131 fun test_strike6
is test
do
132 var md
= """foo ~~~~~~bar~~~~~~ baz\n"""
133 var html
= """<p>foo <del>bar</del> baz</p>\n"""
134 assert md_to_html
(md
) == html
137 fun test_strike_bad
is test
do
138 var md
= """foo ~bar baz\n"""
139 var html
= """<p>foo ~bar baz</p>\n"""
140 assert md_to_html
(md
) == html
143 fun test_strike_bad2
is test
do
144 var md
= """foo ~~bar~ baz\n"""
145 var html
= """<p>foo <del>bar</del> baz</p>\n"""
146 assert md_to_html
(md
) == html
149 fun test_strike_bad3
is test
do
150 var md
= """foo ~~~bar~ baz\n"""
151 var html
= """<p>foo <del>bar</del> baz</p>\n"""
152 assert md_to_html
(md
) == html
155 fun test_strike_bad4
is test
do
156 var md
= """foo ~~~~bar~ baz\n"""
157 var html
= """<p>foo <del>bar</del> baz</p>\n"""
158 assert md_to_html
(md
) == html
161 fun test_strike_bad5
is test
do
162 var md
= """foo ~~~~~bar~ baz\n"""
163 var html
= """<p>foo <del>bar</del> baz</p>\n"""
164 assert md_to_html
(md
) == html
167 fun test_strike_bad6
is test
do
168 var md
= """foo bar~ baz\n"""
169 var html
= """<p>foo bar~ baz</p>\n"""
170 assert md_to_html
(md
) == html
173 fun test_strike_bad7
is test
do
174 var md
= """foo ~bar~~~~ baz\n"""
175 var html
= """<p>foo <del>bar</del>~~~ baz</p>\n"""
176 assert md_to_html
(md
) == html
179 fun test_super1
is test
do
180 var md
= """foo ^bar^ baz\n"""
181 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
182 assert md_to_html
(md
) == html
185 fun test_super2
is test
do
186 var md
= """foo ^^bar^^ baz\n"""
187 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
188 assert md_to_html
(md
) == html
191 fun test_super3
is test
do
192 var md
= """foo ^^^bar^^^ baz\n"""
193 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
194 assert md_to_html
(md
) == html
197 fun test_super4
is test
do
198 var md
= """foo ^^^^bar^^^^ baz\n"""
199 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
200 assert md_to_html
(md
) == html
203 fun test_super5
is test
do
204 var md
= """foo ^^^^^bar^^^^^ baz\n"""
205 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
206 assert md_to_html
(md
) == html
209 fun test_super6
is test
do
210 var md
= """foo ^^^^^^bar^^^^^^ baz\n"""
211 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
212 assert md_to_html
(md
) == html
215 fun test_super_bad1
is test
do
216 var md
= """foo ^bar baz\n"""
217 var html
= """<p>foo ^bar baz</p>\n"""
218 assert md_to_html
(md
) == html
221 fun test_super_bad
is test
do
222 var md
= """foo ^^bar^ baz\n"""
223 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
224 assert md_to_html
(md
) == html
227 fun test_super_bad3
is test
do
228 var md
= """foo ^^^bar^ baz\n"""
229 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
230 assert md_to_html
(md
) == html
233 fun test_super_bad4
is test
do
234 var md
= """foo ^^^^bar^ baz\n"""
235 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
236 assert md_to_html
(md
) == html
239 fun test_super_bad5
is test
do
240 var md
= """foo ^^^^^bar^ baz\n"""
241 var html
= """<p>foo <sup>bar</sup> baz</p>\n"""
242 assert md_to_html
(md
) == html
245 fun test_super_bad6
is test
do
246 var md
= """foo bar^ baz\n"""
247 var html
= """<p>foo bar^ baz</p>\n"""
248 assert md_to_html
(md
) == html
251 fun test_super_bad7
is test
do
252 var md
= """foo ^bar^^^^ baz\n"""
253 var html
= """<p>foo <sup>bar</sup>^^^ baz</p>\n"""
254 assert md_to_html
(md
) == html
262 fun test_strike_md
is test
do
263 var md
= """~~foo~~\n"""
264 assert md_to_md
(md
) == md
267 fun test_super_md
is test
do
268 var md
= """^^foo^^\n"""
269 assert md_to_md
(md
) == md
274 super TestMarkdownMan
277 fun test_strike_man
is test
do
278 var md
= """~~foo~~\n"""
279 var man
= """\n[STRIKEOUT:foo]\n"""
280 assert md_to_man
(md
) == man
283 fun test_super_man
is test
do
284 var md
= """^foo^\n"""
285 var man
= """\nfoo\n"""
286 assert md_to_man
(md
) == man
290 class TestGithubLatex
291 super TestMarkdownLatex
294 fun test_strike_latex
is test
do
299 A \\sout{super} text.
301 assert md_to_tex
(md
) == tex
304 fun test_super_latex
is test
do
309 A \\textsuperscript{super} text.
311 assert md_to_tex
(md
) == tex