Debian Codegraph @

tests/test_syntax/extensions/test_def_list.py

raw
1 """
2 Python Markdown
3
4 A Python implementation of John Gruber's Markdown.
5
6 Documentation: https://python-markdown.github.io/
7 GitHub: https://github.com/Python-Markdown/markdown/
8 PyPI: https://pypi.org/project/Markdown/
9
10 Started by Manfred Stienstra (http://www.dwerg.net/).
11 Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
12 Currently maintained by Waylan Limberg (https://github.com/waylan),
13 Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
14
15 Copyright 2007-2019 The Python Markdown Project (v. 1.7 and later)
16 Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
17 Copyright 2004 Manfred Stienstra (the original version)
18
19 License: BSD (see LICENSE.md for details).
20 """
21
22 from markdown.test_tools import TestCase
23
24
25 class TestDefList(TestCase):
26
27 def test_def_list_with_ol(self):
28 self.assertMarkdownRenders(
29 self.dedent(
30 '''
31
32 term
33
34 : this is a definition for term. it has
35 multiple lines in the first paragraph.
36
37 1. first thing
38
39 first thing details in a second paragraph.
40
41 1. second thing
42
43 second thing details in a second paragraph.
44
45 1. third thing
46
47 third thing details in a second paragraph.
48 '''
49 ),
50 self.dedent(
51 '''
52 <dl>
53 <dt>term</dt>
54 <dd>
55 <p>this is a definition for term. it has
56 multiple lines in the first paragraph.</p>
57 <ol>
58 <li>
59 <p>first thing</p>
60 <p>first thing details in a second paragraph.</p>
61 </li>
62 <li>
63 <p>second thing</p>
64 <p>second thing details in a second paragraph.</p>
65 </li>
66 <li>
67 <p>third thing</p>
68 <p>third thing details in a second paragraph.</p>
69 </li>
70 </ol>
71 </dd>
72 </dl>
73 '''
74 ),
75 extensions=['def_list']
76 )
77
78 def test_def_list_with_ul(self):
79 self.assertMarkdownRenders(
80 self.dedent(
81 '''
82
83 term
84
85 : this is a definition for term. it has
86 multiple lines in the first paragraph.
87
88 - first thing
89
90 first thing details in a second paragraph.
91
92 - second thing
93
94 second thing details in a second paragraph.
95
96 - third thing
97
98 third thing details in a second paragraph.
99 '''
100 ),
101 self.dedent(
102 '''
103 <dl>
104 <dt>term</dt>
105 <dd>
106 <p>this is a definition for term. it has
107 multiple lines in the first paragraph.</p>
108 <ul>
109 <li>
110 <p>first thing</p>
111 <p>first thing details in a second paragraph.</p>
112 </li>
113 <li>
114 <p>second thing</p>
115 <p>second thing details in a second paragraph.</p>
116 </li>
117 <li>
118 <p>third thing</p>
119 <p>third thing details in a second paragraph.</p>
120 </li>
121 </ul>
122 </dd>
123 </dl>
124 '''
125 ),
126 extensions=['def_list']
127 )
128
129 def test_def_list_with_nesting(self):
130 self.assertMarkdownRenders(
131 self.dedent(
132 '''
133
134 term
135
136 : this is a definition for term. it has
137 multiple lines in the first paragraph.
138
139 1. first thing
140
141 first thing details in a second paragraph.
142
143 - first nested thing
144
145 second nested thing details
146 '''
147 ),
148 self.dedent(
149 '''
150 <dl>
151 <dt>term</dt>
152 <dd>
153 <p>this is a definition for term. it has
154 multiple lines in the first paragraph.</p>
155 <ol>
156 <li>
157 <p>first thing</p>
158 <p>first thing details in a second paragraph.</p>
159 <ul>
160 <li>
161 <p>first nested thing</p>
162 <p>second nested thing details</p>
163 </li>
164 </ul>
165 </li>
166 </ol>
167 </dd>
168 </dl>
169 '''
170 ),
171 extensions=['def_list']
172 )
173
174 def test_def_list_with_nesting_self(self):
175 self.assertMarkdownRenders(
176 self.dedent(
177 '''
178
179 term
180
181 : this is a definition for term. it has
182 multiple lines in the first paragraph.
183
184 inception
185
186 : this is a definition for term. it has
187 multiple lines in the first paragraph.
188
189 - bullet point
190
191 another paragraph
192 '''
193 ),
194 self.dedent(
195 '''
196 <dl>
197 <dt>term</dt>
198 <dd>
199 <p>this is a definition for term. it has
200 multiple lines in the first paragraph.</p>
201 <dl>
202 <dt>inception</dt>
203 <dd>
204 <p>this is a definition for term. it has
205 multiple lines in the first paragraph.</p>
206 <ul>
207 <li>bullet point</li>
208 </ul>
209 <p>another paragraph</p>
210 </dd>
211 </dl>
212 </dd>
213 </dl>
214 '''
215 ),
216 extensions=['def_list']
217 )
218
219 def test_def_list_unreasonable_nesting(self):
220 self.assertMarkdownRenders(
221 self.dedent(
222 '''
223
224 turducken
225
226 : this is a definition for term. it has
227 multiple lines in the first paragraph.
228
229 1. ordered list
230
231 - nested list
232
233 term
234
235 : definition
236
237 - item 1 paragraph 1
238
239 item 1 paragraph 2
240 '''
241 ),
242 self.dedent(
243 '''
244 <dl>
245 <dt>turducken</dt>
246 <dd>
247 <p>this is a definition for term. it has
248 multiple lines in the first paragraph.</p>
249 <ol>
250 <li>
251 <p>ordered list</p>
252 <ul>
253 <li>
254 <p>nested list</p>
255 <dl>
256 <dt>term</dt>
257 <dd>
258 <p>definition</p>
259 <ul>
260 <li>
261 <p>item 1 paragraph 1</p>
262 <p>item 1 paragraph 2</p>
263 </li>
264 </ul>
265 </dd>
266 </dl>
267 </li>
268 </ul>
269 </li>
270 </ol>
271 </dd>
272 </dl>
273 '''
274 ),
275 extensions=['def_list']
276 )
277
278 def test_def_list_nested_admontions(self):
279 self.assertMarkdownRenders(
280 self.dedent(
281 '''
282 term
283
284 : definition
285
286 !!! note "Admontion"
287
288 term
289
290 : definition
291
292 1. list
293
294 continue
295 '''
296 ),
297 self.dedent(
298 '''
299 <dl>
300 <dt>term</dt>
301 <dd>
302 <p>definition</p>
303 <div class="admonition note">
304 <p class="admonition-title">Admontion</p>
305 <dl>
306 <dt>term</dt>
307 <dd>
308 <p>definition</p>
309 <ol>
310 <li>
311 <p>list</p>
312 <p>continue</p>
313 </li>
314 </ol>
315 </dd>
316 </dl>
317 </div>
318 </dd>
319 </dl>
320 '''
321 ),
322 extensions=['def_list', 'admonition']
323 )