Debian Codegraph @

tests/test_extensions/test_critic.py

raw
1 """Test caret."""
2 from .. import util
3
4 class TestCriticViewMode(util.MdCase):
5 """Test view mode."""
6
7 extension = [
8 'pymdownx.critic'
9 ]
10 extension_configs = {
11 "pymdownx.critic": {
12 "mode": 'view'
13 }
14 }
15
16 def test_view(self):
17 """Test view mode."""
18
19 self.check_markdown(
20 R"""
21 Here is some {--*incorrect*--} Markdown. I am adding this{++ here.++}. Here is some more {--text
22 that I am removing--}text. And here is even more {++text that I
23 am ++}adding.{~~
24
25 ~> ~~}Paragraph was deleted and replaced with some spaces.{~~ ~>
26
27 ~~}Spaces were removed and a paragraph was added.
28
29 And here is a comment on {==some
30 ==text== ==}{>>This works quite well. I just wanted to comment on it.<<}. Substitutions {~~is~>are~~} great!
31
32 General block handling.
33
34 {--
35
36 * test
37 * test
38 * test
39 * test
40 * test
41
42 --}
43
44 {++
45
46 * test
47 * test
48 * test
49 * test
50 * test
51
52 ++}
53 """, # noqa: E501
54 """
55 <p>Here is some <del class="critic"><em>incorrect</em></del> Markdown. I am adding this<ins class="critic"> here.</ins>. Here is some more <del class="critic">text
56 that I am removing</del>text. And here is even more <ins class="critic">text that I
57 am </ins>adding.<del class="critic break">&nbsp;</del><ins class="critic"> </ins>Paragraph was deleted and replaced with some spaces.<del class="critic"> </del></p>
58 <ins class="critic break">&nbsp;</ins>
59 <p>Spaces were removed and a paragraph was added.</p>
60 <p>And here is a comment on <mark class="critic">some
61 ==text== </mark><span class="critic comment">This works quite well. I just wanted to comment on it.</span>. Substitutions <del class="critic">is</del><ins class="critic">are</ins> great!</p>
62 <p>General block handling.</p>
63 <del class="critic block">
64 <ul>
65 <li>test</li>
66 <li>test</li>
67 <li>test<ul>
68 <li>test</li>
69 </ul>
70 </li>
71 <li>test</li>
72 </ul>
73 </del>
74 <ins class="critic block">
75 <ul>
76 <li>test<ul>
77 <li>test</li>
78 </ul>
79 </li>
80 <li>test</li>
81 <li>test</li>
82 <li>test</li>
83 </ul>
84 </ins>
85 """, # noqa: E501
86 True
87 )
88
89
90 class TestCriticAcceptMode(util.MdCase):
91 """Test accept mode."""
92
93 extension = [
94 'pymdownx.critic'
95 ]
96 extension_configs = {
97 "pymdownx.critic": {
98 "mode": 'accept'
99 }
100 }
101
102 def test_accept(self):
103 """Test accept mode."""
104
105 self.check_markdown(
106 R"""
107 Here is some {--*incorrect*--} Markdown. I am adding this{++ here.++}. Here is some more {--text
108 that I am removing--}text. And here is even more {++text that I
109 am ++}adding.{~~
110
111 ~> ~~}Paragraph was deleted and replaced with some spaces.{~~ ~>
112
113 ~~}Spaces were removed and a paragraph was added.
114
115 And here is a comment on {==some
116 ==text== ==}{>>This works quite well. I just wanted to comment on it.<<}. Substitutions {~~is~>are~~} great!
117
118 General block handling.
119
120 {--
121
122 * test
123 * test
124 * test
125 * test
126 * test
127
128 --}
129
130 {++
131
132 * test
133 * test
134 * test
135 * test
136 * test
137
138 ++}
139 """, # noqa: E501
140 """
141 <p>Here is some Markdown. I am adding this here.. Here is some more text. And here is even more text that I
142 am adding. Paragraph was deleted and replaced with some spaces.</p>
143 <p>Spaces were removed and a paragraph was added.</p>
144 <p>And here is a comment on some
145 ==text== . Substitutions are great!</p>
146 <p>General block handling.</p>
147 <ul>
148 <li>test<ul>
149 <li>test</li>
150 </ul>
151 </li>
152 <li>test</li>
153 <li>test</li>
154 <li>test</li>
155 </ul>
156 """, # noqa: E501
157 True
158 )
159
160
161 class TestCriticRejectMode(util.MdCase):
162 """Test reject mode."""
163
164 extension = [
165 'pymdownx.critic'
166 ]
167 extension_configs = {
168 "pymdownx.critic": {
169 "mode": 'reject'
170 }
171 }
172
173 def test_reject(self):
174 """Test reject mode."""
175
176 self.check_markdown(
177 R"""
178 Here is some {--*incorrect*--} Markdown. I am adding this{++ here.++}. Here is some more {--text
179 that I am removing--}text. And here is even more {++text that I
180 am ++}adding.{~~
181
182 ~> ~~}Paragraph was deleted and replaced with some spaces.{~~ ~>
183
184 ~~}Spaces were removed and a paragraph was added.
185
186 And here is a comment on {==some
187 ==text== ==}{>>This works quite well. I just wanted to comment on it.<<}. Substitutions {~~is~>are~~} great!
188
189 General block handling.
190
191 {--
192
193 * test
194 * test
195 * test
196 * test
197 * test
198
199 --}
200
201 {++
202
203 * test
204 * test
205 * test
206 * test
207 * test
208
209 ++}
210 """, # noqa: E501
211 """
212 <p>Here is some <em>incorrect</em> Markdown. I am adding this. Here is some more text
213 that I am removingtext. And here is even more adding.</p>
214 <p>Paragraph was deleted and replaced with some spaces. Spaces were removed and a paragraph was added.</p>
215 <p>And here is a comment on some
216 ==text== . Substitutions is great!</p>
217 <p>General block handling.</p>
218 <ul>
219 <li>test</li>
220 <li>test</li>
221 <li>test<ul>
222 <li>test</li>
223 </ul>
224 </li>
225 <li>test</li>
226 </ul>
227 """,
228 True
229 )
230
231
232 class TestCriticEscapeAll(util.MdCase):
233 """Test critic with escaping."""
234
235 extension = [
236 'pymdownx.critic',
237 'pymdownx.escapeall'
238 ]
239 extension_configs = {
240 "pymdownx.critic": {
241 "mode": 'view'
242 }
243 }
244
245 def test_escape(self):
246 """Test with escapes."""
247
248 self.check_markdown(
249 R"""
250 We shouldn't escape STX and ETX characters:
251
252 Don't escape crtiic placeholder: \{>>comment<<}
253 """,
254 """
255 <p>We shouldn't escape STX and ETX characters:</p>
256 <p>Don't escape crtiic placeholder: <span class="critic comment">comment</span></p>
257 """,
258 True
259 )