Debian Codegraph @

tests/test_extensions/test_quotes.py

raw
1 """Test cases for Quotes."""
2 from .. import util
3
4
5 class TestQuotes(util.MdCase):
6 """Test cases for repo link shortening."""
7
8 extension = [
9 'pymdownx.superfences',
10 'pymdownx.quotes',
11 ]
12
13 extension_configs = {
14 'pymdownx.quotes': {
15 'callouts': True
16 }
17 }
18
19 def test_separate_quotes(self):
20 """Test separate quotes."""
21
22 self.check_markdown(
23 """
24 > This is a paragraph
25
26 > This is another paragraph.
27 """,
28 """
29 <blockquote>
30 <p>This is a paragraph</p>
31 </blockquote>
32 <blockquote>
33 <p>This is another paragraph.</p>
34 </blockquote>
35 """,
36 True
37 )
38
39 def test_together_quotes(self):
40 """Test quotes together."""
41
42 self.check_markdown(
43 """
44 > This is a paragraph
45 >
46 > This is another paragraph.
47 """,
48 """
49 <blockquote>
50 <p>This is a paragraph</p>
51 <p>This is another paragraph.</p>
52 </blockquote>
53 """,
54 True
55 )
56
57 def test_callout(self):
58 """Test callout."""
59
60 self.check_markdown(
61 """
62 > [!note]
63 > Here is a note
64 """,
65 """
66 <div class="admonition note">
67 <p class="admonition-title">Note</p>
68 <p>Here is a note</p>
69 </div>
70 """,
71 True
72 )
73
74 def test_callout_case(self):
75 """Test callout class case insensitive."""
76
77 self.check_markdown(
78 """
79 > [!NOTE]
80 > Here is a note
81 """,
82 """
83 <div class="admonition note">
84 <p class="admonition-title">Note</p>
85 <p>Here is a note</p>
86 </div>
87 """,
88 True
89 )
90
91 def test_callout_title(self):
92 """Test callout title."""
93
94 self.check_markdown(
95 """
96 > [!tip] Here's a tip
97 > Use a custom title!
98 """,
99 """
100 <div class="admonition tip">
101 <p class="admonition-title">Here's a tip</p>
102 <p>Use a custom title!</p>
103 </div>
104 """,
105 True
106 )
107
108 def test_callout_open(self):
109 """Test callout open."""
110
111 self.check_markdown(
112 """
113 > [!danger]+ Click to see more
114 > I'm collapsible.
115 """,
116 """
117 <details class="danger" open="open">
118 <summary>Click to see more</summary>
119 <p>I'm collapsible.</p>
120 </details>
121 """,
122 True
123 )
124
125 def test_callout_closed(self):
126 """Test callout closed."""
127
128 self.check_markdown(
129 """
130 > [!danger]- Click to see more
131 > I'm collapsible.
132 """,
133 """
134 <details class="danger">
135 <summary>Click to see more</summary>
136 <p>I'm collapsible.</p>
137 </details>
138 """,
139 True
140 )
141
142 def test_blank_start(self):
143 """Test blank start."""
144
145 self.check_markdown(
146 """
147 >
148 > [!note]
149 > This is a note
150
151 >
152 >>
153 >> [!note]
154 >> This is a note
155 """,
156 """
157 <div class="admonition note">
158 <p class="admonition-title">Note</p>
159 <p>This is a note</p>
160 </div>
161 <blockquote>
162 <div class="admonition note">
163 <p class="admonition-title">Note</p>
164 <p>This is a note</p>
165 </div>
166 </blockquote>
167 """,
168 True
169 )
170
171 def test_superfences(self):
172 """Test Quotes with SuperFences."""
173
174 self.check_markdown(
175 """
176 This will work.
177
178 > ```
179 > Test
180 >
181 > Test
182 > ```
183
184 This will not.
185
186 > ```
187 > Test
188
189 > Test
190 > ```
191 """,
192 """
193 <p>This will work.</p>
194 <blockquote>
195 <div class="highlight"><pre><span></span><code>Test
196
197 Test
198 </code></pre></div>
199 </blockquote>
200 <p>This will not.</p>
201 <blockquote>
202 <p>```
203 Test</p>
204 </blockquote>
205 <blockquote>
206 <p>Test
207 ```</p>
208 </blockquote>
209 """,
210 True
211 )
212
213 def test_multi_class(self):
214 """Test multiple classes."""
215
216 self.check_markdown(
217 """
218 > [!note | inline | end]
219 > This is a note
220 """,
221 """
222 <div class="admonition note inline end">
223 <p class="admonition-title">Note</p>
224 <p>This is a note</p>
225 </div>
226 """,
227 True
228 )
229
230 def test_multi_class_case(self):
231 """Ensure first class is case insensitive."""
232
233 self.check_markdown(
234 """
235 > [!NOTE | INLINE | END]
236 > This is a note
237 """,
238 """
239 <div class="admonition note INLINE END">
240 <p class="admonition-title">Note</p>
241 <p>This is a note</p>
242 </div>
243 """,
244 True
245 )
246
247 def test_nested(self):
248 """Test nested content."""
249
250 self.check_markdown(
251 """
252 > [!note]
253 > Content
254 > > [!danger]
255 > > Content
256 > > > [!important]
257 > > > Content
258 > > Content
259 > >
260 > > Content
261 >
262 > > [!tip]
263 """,
264 """
265 <div class="admonition note">
266 <p class="admonition-title">Note</p>
267 <p>Content</p>
268 <div class="admonition danger">
269 <p class="admonition-title">Danger</p>
270 <p>Content</p>
271 <div class="admonition important">
272 <p class="admonition-title">Important</p>
273 <p>Content
274 Content</p>
275 </div>
276 <p>Content</p>
277 </div>
278 <div class="admonition tip">
279 <p class="admonition-title">Tip
280 </p>
281 </div>
282 </div>
283 """,
284 True
285 )