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_images
is test
19 class TestCommonmarkImages
20 super TestMarkdownHtml
23 fun test546
is test
do
24 var md
= """![foo](/url "title")\n"""
25 var html
= """<p><img src="/url" alt="foo" title="title" /></p>\n"""
26 assert md_to_html
(md
) == html
29 fun test547
is test
do
30 var md
= """![foo *bar*]\n\n[foo *bar*]: train.jpg "train & tracks"\n"""
31 var html
= """<p><img src="train.jpg" alt="foo bar" title="train & tracks" /></p>\n"""
32 assert md_to_html
(md
) == html
35 fun test548
is test
do
36 var md
= """![foo ![bar](/url)](/url2)\n"""
37 var html
= """<p><img src="/url2" alt="foo bar" /></p>\n"""
38 assert md_to_html
(md
) == html
41 fun test549
is test
do
42 var md
= """![foo [bar](/url)](/url2)\n"""
43 var html
= """<p><img src="/url2" alt="foo bar" /></p>\n"""
44 assert md_to_html
(md
) == html
47 fun test550
is test
do
48 var md
= """![foo *bar*][]\n\n[foo *bar*]: train.jpg "train & tracks"\n"""
49 var html
= """<p><img src="train.jpg" alt="foo bar" title="train & tracks" /></p>\n"""
50 assert md_to_html
(md
) == html
53 fun test551
is test
do
54 var md
= """![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg "train & tracks"\n"""
55 var html
= """<p><img src="train.jpg" alt="foo bar" title="train & tracks" /></p>\n"""
56 assert md_to_html
(md
) == html
59 fun test552
is test
do
60 var md
= """![foo](train.jpg)\n"""
61 var html
= """<p><img src="train.jpg" alt="foo" /></p>\n"""
62 assert md_to_html
(md
) == html
65 fun test553
is test
do
66 var md
= """My ![foo bar](/path/to/train.jpg "title" )\n"""
67 var html
= """<p>My <img src="/path/to/train.jpg" alt="foo bar" title="title" /></p>\n"""
68 assert md_to_html
(md
) == html
71 fun test554
is test
do
72 var md
= """![foo](<url>)\n"""
73 var html
= """<p><img src="url" alt="foo" /></p>\n"""
74 assert md_to_html
(md
) == html
77 fun test555
is test
do
78 var md
= """![](/url)\n"""
79 var html
= """<p><img src="/url" alt="" /></p>\n"""
80 assert md_to_html
(md
) == html
83 fun test556
is test
do
84 var md
= """![foo][bar]\n\n[bar]: /url\n"""
85 var html
= """<p><img src="/url" alt="foo" /></p>\n"""
86 assert md_to_html
(md
) == html
89 fun test557
is test
do
90 var md
= """![foo][bar]\n\n[BAR]: /url\n"""
91 var html
= """<p><img src="/url" alt="foo" /></p>\n"""
92 assert md_to_html
(md
) == html
95 fun test558
is test
do
96 var md
= """![foo][]\n\n[foo]: /url "title"\n"""
97 var html
= """<p><img src="/url" alt="foo" title="title" /></p>\n"""
98 assert md_to_html
(md
) == html
101 fun test559
is test
do
102 var md
= """![*foo* bar][]\n\n[*foo* bar]: /url "title"\n"""
103 var html
= """<p><img src="/url" alt="foo bar" title="title" /></p>\n"""
104 assert md_to_html
(md
) == html
107 fun test560
is test
do
108 var md
= """![Foo][]\n\n[foo]: /url "title"\n"""
109 var html
= """<p><img src="/url" alt="Foo" title="title" /></p>\n"""
110 assert md_to_html
(md
) == html
113 fun test561
is test
do
114 var md
= """![foo] \n[]\n\n[foo]: /url "title"\n"""
115 var html
= """<p><img src="/url" alt="foo" title="title" />\n[]</p>\n"""
116 assert md_to_html
(md
) == html
119 fun test562
is test
do
120 var md
= """![foo]\n\n[foo]: /url "title"\n"""
121 var html
= """<p><img src="/url" alt="foo" title="title" /></p>\n"""
122 assert md_to_html
(md
) == html
125 fun test563
is test
do
126 var md
= """![*foo* bar]\n\n[*foo* bar]: /url "title"\n"""
127 var html
= """<p><img src="/url" alt="foo bar" title="title" /></p>\n"""
128 assert md_to_html
(md
) == html
131 fun test564
is test
do
132 var md
= """![[foo]]\n\n[[foo]]: /url "title"\n"""
133 var html
= """<p>![[foo]]</p>\n<p>[[foo]]: /url "title"</p>\n"""
134 assert md_to_html
(md
) == html
137 fun test565
is test
do
138 var md
= """![Foo]\n\n[foo]: /url "title"\n"""
139 var html
= """<p><img src="/url" alt="Foo" title="title" /></p>\n"""
140 assert md_to_html
(md
) == html
143 fun test566
is test
do
144 var md
= """!\\[foo]\n\n[foo]: /url "title"\n"""
145 var html
= """<p>![foo]</p>\n"""
146 assert md_to_html
(md
) == html
149 fun test567
is test
do
150 var md
= """\\![foo]\n\n[foo]: /url "title"\n"""
151 var html
= """<p>!<a href="/url" title="title">foo</a></p>\n"""
152 assert md_to_html
(md
) == html