Merge: src/model/model_index: model index uses BKTree
[nit.git] / lib / markdown2 / tests / test_markdown_issues.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
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
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 # Tests related to markdown issues from the Git repo
16 #
17 # Fixing:
18 #
19 # * 1525: lib/markdown: issue with nested fences
20 # * 2507: markdown: some lines are lost in verbatim blocks inside a list
21 #
22 # See <https://github.com/nitlang/nit/issues>.
23 module test_markdown_issues is test
24
25 import test_markdown
26
27 class TestMarkdownIssues
28 super TestMarkdownHtml
29 test
30
31 # See <https://github.com/nitlang/nit/issues/1525>.
32 fun test_issue_1525_1 is test do
33 var md = """
34 A fence within a fence
35 ~~~~~~
36 some code:
37 ~~~
38 some other code
39 ~~~
40 ~~~~~~
41 """
42 var html = """
43 <p>A fence within a fence</p>
44 <pre><code>some code:
45 ~~~
46 some other code
47 ~~~
48 </code></pre>
49 """
50 assert md_to_html(md) == html
51 end
52
53 # See <https://github.com/nitlang/nit/issues/1525>.
54 fun test_issue_1525_2 is test do
55 var md = """
56 A fence within a fence
57 ~~~
58 some code:
59 ```
60 some other code
61 ```
62 ~~~
63 """
64 var html = """
65 <p>A fence within a fence</p>
66 <pre><code>some code:
67 ```
68 some other code
69 ```
70 </code></pre>
71 """
72 assert md_to_html(md) == html
73 end
74
75 # See <https://github.com/nitlang/nit/issues/1525>.
76 fun test_issue_1525_3 is test do
77 var md = """
78 A fence within a fence
79 ```
80 some code:
81 ~~~
82 some other code
83 ~~~
84 ```
85 """
86 var html = """
87 <p>A fence within a fence</p>
88 <pre><code>some code:
89 ~~~
90 some other code
91 ~~~
92 </code></pre>
93 """
94 assert md_to_html(md) == html
95 end
96
97 # See <https://github.com/nitlang/nit/issues/2507>.
98 fun test_issue_2507_1 is test do
99 var md = """
100 * 4 spaces, `asdf` and `tab.` are lost
101 ~~~
102 a
103 as
104 asd
105 asdf
106 tab.
107 asdfg
108 ~~~
109 """
110 var html = """
111 <ul>
112 <li>4 spaces, <code>asdf</code> and <code>tab.</code> are lost
113 <pre><code>a
114 as
115 asd
116 asdf
117 tab.
118 asdfg
119 </code></pre>
120 </li>
121 </ul>
122 """
123 assert md_to_html(md) == html
124 end
125
126 # See <https://github.com/nitlang/nit/issues/2507>.
127 fun test_issue_2507_2 is test do
128 var md = """
129 * 2 spaces, `as` is lost
130
131 ~~~
132 a
133 as
134 asd
135 asdf
136 ~~~
137 """
138 var html = """
139 <ul>
140 <li>
141 <p>2 spaces, <code>as</code> is lost</p>
142 <pre><code>a
143 as
144 asd
145 asdf
146 </code></pre>
147 </li>
148 </ul>
149 """
150 assert md_to_html(md) == html
151 end
152 end