| 1 |
"""Test cases for SuperFences.""" |
| 2 |
from .. import util |
| 3 |
import pymdownx.arithmatex as arithmatex |
| 4 |
import pymdownx.superfences as superfences |
| 5 |
from pymdownx.superfences import SuperFencesException |
| 6 |
import warnings |
| 7 |
|
| 8 |
|
| 9 |
def custom_format(source, language, class_name, options, md, **kwargs): |
| 10 |
"""Custom format.""" |
| 11 |
|
| 12 |
return '<div lang="{}" class_name="class-{}", option="{}">{}</div>'.format(language, class_name, |
| 13 |
options['opt'], source) |
| 14 |
|
| 15 |
|
| 16 |
def default_format(source, language, class_name, options, md, **kwargs): |
| 17 |
"""Default format.""" |
| 18 |
|
| 19 |
return '<custom lang="{}" class_name="class-{}">{}</custom>'.format(language, class_name, source) |
| 20 |
|
| 21 |
|
| 22 |
def custom_exploder(source, language, class_name, options, md, **kwargs): |
| 23 |
"""Broken format.""" |
| 24 |
|
| 25 |
raise Exception('Boom!') |
| 26 |
|
| 27 |
|
| 28 |
def custom_exploder_fail(source, language, class_name, options, md, **kwargs): |
| 29 |
"""Broken format.""" |
| 30 |
|
| 31 |
raise SuperFencesException('Boom!') |
| 32 |
|
| 33 |
|
| 34 |
def custom_validator_exploder(language, inputs, options, attrs, md): |
| 35 |
"""Broken validator.""" |
| 36 |
|
| 37 |
raise Exception('Boom!') |
| 38 |
|
| 39 |
|
| 40 |
def custom_validator(language, inputs, options, attrs, md): |
| 41 |
"""Custom validator.""" |
| 42 |
|
| 43 |
okay = True |
| 44 |
for k in inputs.keys(): |
| 45 |
if k != 'opt': |
| 46 |
okay = False |
| 47 |
break |
| 48 |
if okay: |
| 49 |
if inputs['opt'] != "A": |
| 50 |
okay = False |
| 51 |
else: |
| 52 |
options['opt'] = inputs['opt'] |
| 53 |
|
| 54 |
return okay |
| 55 |
|
| 56 |
|
| 57 |
def custom_validator_except(language, inputs, options, attrs, md): |
| 58 |
"""Custom validator.""" |
| 59 |
|
| 60 |
okay = True |
| 61 |
try: |
| 62 |
for k in inputs.keys(): |
| 63 |
if k != 'opt': |
| 64 |
okay = False |
| 65 |
break |
| 66 |
if okay: |
| 67 |
if inputs['opt'] != "A": |
| 68 |
okay = False |
| 69 |
else: |
| 70 |
options['opt'] = inputs['opt'] |
| 71 |
except KeyError as e: |
| 72 |
raise SuperFencesException from e |
| 73 |
|
| 74 |
return okay |
| 75 |
|
| 76 |
|
| 77 |
class TestHighlightTitle(util.MdCase): |
| 78 |
"""Test title cases.""" |
| 79 |
|
| 80 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 81 |
|
| 82 |
def test_title(self): |
| 83 |
"""Test auto title.""" |
| 84 |
|
| 85 |
self.check_markdown( |
| 86 |
r''' |
| 87 |
```pycon title="My title" |
| 88 |
>>> import test |
| 89 |
``` |
| 90 |
''', |
| 91 |
r''' |
| 92 |
<div class="highlight"><span class="filename">My title</span><pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 93 |
</code></pre></div> |
| 94 |
''', # noqa: E501 |
| 95 |
True |
| 96 |
) |
| 97 |
|
| 98 |
def test_title_table(self): |
| 99 |
"""Test auto title.""" |
| 100 |
|
| 101 |
self.check_markdown( |
| 102 |
r''' |
| 103 |
```pycon title="My title" linenums="1" |
| 104 |
>>> import test |
| 105 |
``` |
| 106 |
''', |
| 107 |
r''' |
| 108 |
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">My title</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 109 |
</code></pre></div></td></tr></table></div> |
| 110 |
''', # noqa: E501 |
| 111 |
True |
| 112 |
) |
| 113 |
|
| 114 |
|
| 115 |
class TestHighlightStrip(util.MdCase): |
| 116 |
"""Test Highlight's stripping of new lines.""" |
| 117 |
|
| 118 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 119 |
extension_configs = {'pymdownx.highlight': {'stripnl': False}} |
| 120 |
|
| 121 |
def test_no_stripnl(self): |
| 122 |
"""Test no stripping of leading and trailing new lines.""" |
| 123 |
|
| 124 |
self.check_markdown( |
| 125 |
r''' |
| 126 |
```py |
| 127 |
|
| 128 |
import foo |
| 129 |
|
| 130 |
|
| 131 |
import bar |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
``` |
| 136 |
''', |
| 137 |
r''' |
| 138 |
<div class="highlight"><pre><span></span><code> |
| 139 |
<span class="kn">import</span><span class="w"> </span><span class="nn">foo</span> |
| 140 |
|
| 141 |
|
| 142 |
<span class="kn">import</span><span class="w"> </span><span class="nn">bar</span> |
| 143 |
|
| 144 |
|
| 145 |
</code></pre></div> |
| 146 |
''', |
| 147 |
True |
| 148 |
) |
| 149 |
|
| 150 |
|
| 151 |
class TestHighlightAutoTitleOverride(util.MdCase): |
| 152 |
"""Test title cases.""" |
| 153 |
|
| 154 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 155 |
extension_configs = { |
| 156 |
'pymdownx.highlight': { |
| 157 |
'auto_title': True, |
| 158 |
"auto_title_map": { |
| 159 |
"Python Console Session": "Python" |
| 160 |
} |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
def test_auto_tile(self): |
| 165 |
"""Test auto title.""" |
| 166 |
|
| 167 |
self.check_markdown( |
| 168 |
r''' |
| 169 |
```{.python title="My Title"} |
| 170 |
import test |
| 171 |
``` |
| 172 |
''', |
| 173 |
r''' |
| 174 |
<div class="highlight"><span class="filename">My Title</span><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 175 |
</code></pre></div> |
| 176 |
''', # noqa: E501 |
| 177 |
True |
| 178 |
) |
| 179 |
|
| 180 |
def test_auto_tile_map(self): |
| 181 |
"""Test auto title.""" |
| 182 |
|
| 183 |
self.check_markdown( |
| 184 |
r''' |
| 185 |
```{.pycon title="My Title"} |
| 186 |
>>> import test |
| 187 |
``` |
| 188 |
''', |
| 189 |
r''' |
| 190 |
<div class="highlight"><span class="filename">My Title</span><pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 191 |
</code></pre></div> |
| 192 |
''', # noqa: E501 |
| 193 |
True |
| 194 |
) |
| 195 |
|
| 196 |
|
| 197 |
class TestHighlightLineWrapsInline(util.MdCase): |
| 198 |
"""Test highlight line wraps.""" |
| 199 |
|
| 200 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 201 |
extension_configs = { |
| 202 |
'pymdownx.highlight': { |
| 203 |
'line_spans': '__my_span', |
| 204 |
'linenums_style': 'inline' |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
def test_linespans(self): |
| 209 |
"""Test wrapping a line in line spans.""" |
| 210 |
|
| 211 |
self.check_markdown( |
| 212 |
r''' |
| 213 |
```python linenums="2" |
| 214 |
import test |
| 215 |
``` |
| 216 |
''', |
| 217 |
r''' |
| 218 |
<div class="highlight"><pre><span></span><code><span id="__my_span-0-2"><span class="linenos">2</span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 219 |
</span></code></pre></div> |
| 220 |
''', # noqa: E501 |
| 221 |
True |
| 222 |
) |
| 223 |
|
| 224 |
|
| 225 |
class TestHighlightLineWrapsPymdownxInline(util.MdCase): |
| 226 |
"""Test highlight line wraps.""" |
| 227 |
|
| 228 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 229 |
extension_configs = { |
| 230 |
'pymdownx.highlight': { |
| 231 |
'line_spans': '__my_span', |
| 232 |
'linenums_style': 'pymdownx-inline' |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 236 |
def test_linespans(self): |
| 237 |
"""Test wrapping a line in line spans.""" |
| 238 |
|
| 239 |
self.check_markdown( |
| 240 |
r''' |
| 241 |
```python linenums="2" |
| 242 |
import test |
| 243 |
``` |
| 244 |
''', |
| 245 |
r''' |
| 246 |
<div class="highlight"><pre><span></span><code><span id="__my_span-0-2"><span class="linenos" data-linenos="2 "></span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 247 |
</span></code></pre></div> |
| 248 |
''', # noqa: E501 |
| 249 |
True |
| 250 |
) |
| 251 |
|
| 252 |
|
| 253 |
class TestHighlightLineWrapsPymdownsTable(util.MdCase): |
| 254 |
"""Test highlight line wraps.""" |
| 255 |
|
| 256 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 257 |
extension_configs = { |
| 258 |
'pymdownx.highlight': { |
| 259 |
'line_spans': '__my_span', |
| 260 |
'linenums_style': 'table' |
| 261 |
} |
| 262 |
} |
| 263 |
|
| 264 |
def test_linespans(self): |
| 265 |
"""Test wrapping a line in line spans.""" |
| 266 |
|
| 267 |
self.check_markdown( |
| 268 |
r''' |
| 269 |
```python linenums="2" |
| 270 |
import test |
| 271 |
``` |
| 272 |
''', |
| 273 |
r''' |
| 274 |
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__my_span-0-2"><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 275 |
</span></code></pre></div></td></tr></table></div> |
| 276 |
''', # noqa: E501 |
| 277 |
True |
| 278 |
) |
| 279 |
|
| 280 |
|
| 281 |
class TestHighlightLineAnchorsInline(util.MdCase): |
| 282 |
"""Test highlight line wraps.""" |
| 283 |
|
| 284 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 285 |
extension_configs = { |
| 286 |
'pymdownx.highlight': { |
| 287 |
'line_anchors': '__my_span', |
| 288 |
'linenums_style': 'inline' |
| 289 |
} |
| 290 |
} |
| 291 |
|
| 292 |
def test_linespans(self): |
| 293 |
"""Test wrapping a line in line spans.""" |
| 294 |
|
| 295 |
self.check_markdown( |
| 296 |
r''' |
| 297 |
```python linenums="2" |
| 298 |
import test |
| 299 |
``` |
| 300 |
''', |
| 301 |
r''' |
| 302 |
<div class="highlight"><pre><span></span><code><a id="__my_span-0-2" name="__my_span-0-2"></a><span class="linenos">2</span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 303 |
</code></pre></div> |
| 304 |
''', # noqa: E501 |
| 305 |
True |
| 306 |
) |
| 307 |
|
| 308 |
|
| 309 |
class TestHighlightLineAnchorsPymdownxInline(util.MdCase): |
| 310 |
"""Test highlight line wraps.""" |
| 311 |
|
| 312 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 313 |
extension_configs = { |
| 314 |
'pymdownx.highlight': { |
| 315 |
'line_anchors': '__my_span', |
| 316 |
'linenums_style': 'pymdownx-inline' |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
def test_linespans(self): |
| 321 |
"""Test wrapping a line in line spans.""" |
| 322 |
|
| 323 |
self.check_markdown( |
| 324 |
r''' |
| 325 |
```python linenums="2" |
| 326 |
import test |
| 327 |
``` |
| 328 |
''', |
| 329 |
r''' |
| 330 |
<div class="highlight"><pre><span></span><code><a id="__my_span-0-2" name="__my_span-0-2"></a><span class="linenos" data-linenos="2 "></span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 331 |
</code></pre></div> |
| 332 |
''', # noqa: E501 |
| 333 |
True |
| 334 |
) |
| 335 |
|
| 336 |
|
| 337 |
class TestHighlightLineAnchorsPymdownsTable(util.MdCase): |
| 338 |
"""Test highlight line wraps.""" |
| 339 |
|
| 340 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 341 |
extension_configs = { |
| 342 |
'pymdownx.highlight': { |
| 343 |
'line_anchors': '__my_span', |
| 344 |
'linenums_style': 'table' |
| 345 |
} |
| 346 |
} |
| 347 |
|
| 348 |
def test_linespans(self): |
| 349 |
"""Test wrapping a line in line spans.""" |
| 350 |
|
| 351 |
self.check_markdown( |
| 352 |
r''' |
| 353 |
```python linenums="2" |
| 354 |
import test |
| 355 |
``` |
| 356 |
''', |
| 357 |
r''' |
| 358 |
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__my_span-0-2" name="__my_span-0-2"></a><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 359 |
</code></pre></div></td></tr></table></div> |
| 360 |
''', # noqa: E501 |
| 361 |
True |
| 362 |
) |
| 363 |
|
| 364 |
|
| 365 |
class TestHighlightAnchorLinenumInline(util.MdCase): |
| 366 |
"""Test highlight line wraps.""" |
| 367 |
|
| 368 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 369 |
extension_configs = { |
| 370 |
'pymdownx.highlight': { |
| 371 |
'anchor_linenums': True, |
| 372 |
'linenums_style': 'inline' |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
def test_linespans(self): |
| 377 |
"""Test wrapping a line in line spans.""" |
| 378 |
|
| 379 |
self.check_markdown( |
| 380 |
r''' |
| 381 |
```python linenums="2" |
| 382 |
import test |
| 383 |
``` |
| 384 |
''', |
| 385 |
r''' |
| 386 |
<div class="highlight"><pre><span></span><code><a id="__codelineno-0-2" name="__codelineno-0-2"></a><a href="#__codelineno-0-2"><span class="linenos">2</span></a><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 387 |
</code></pre></div> |
| 388 |
''', # noqa: E501 |
| 389 |
True |
| 390 |
) |
| 391 |
|
| 392 |
def test_linespans_id(self): |
| 393 |
"""Test wrapping a line in line spans with an ID.""" |
| 394 |
|
| 395 |
self.check_markdown( |
| 396 |
r''' |
| 397 |
```{.python #id linenums="2"} |
| 398 |
import test |
| 399 |
``` |
| 400 |
''', |
| 401 |
r''' |
| 402 |
<div id="id" class="highlight"><pre><span></span><code><a id="__codelineno-id-2" name="__codelineno-id-2"></a><a href="#__codelineno-id-2"><span class="linenos">2</span></a><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 403 |
</code></pre></div> |
| 404 |
''', # noqa: E501 |
| 405 |
True |
| 406 |
) |
| 407 |
|
| 408 |
|
| 409 |
class TestHighlightAnchorLinenumsPymdownxInline(util.MdCase): |
| 410 |
"""Test highlight line wraps.""" |
| 411 |
|
| 412 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 413 |
extension_configs = { |
| 414 |
'pymdownx.highlight': { |
| 415 |
'anchor_linenums': True, |
| 416 |
'linenums_style': 'pymdownx-inline' |
| 417 |
} |
| 418 |
} |
| 419 |
|
| 420 |
def test_linespans(self): |
| 421 |
"""Test wrapping a line in line spans.""" |
| 422 |
|
| 423 |
self.check_markdown( |
| 424 |
r''' |
| 425 |
```python linenums="2" |
| 426 |
import test |
| 427 |
``` |
| 428 |
''', |
| 429 |
r''' |
| 430 |
<div class="highlight"><pre><span></span><code><a id="__codelineno-0-2" name="__codelineno-0-2"></a><a href="#__codelineno-0-2"><span class="linenos" data-linenos="2 "></span></a><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 431 |
</code></pre></div> |
| 432 |
''', # noqa: E501 |
| 433 |
True |
| 434 |
) |
| 435 |
|
| 436 |
def test_linespans_id(self): |
| 437 |
"""Test wrapping a line in line spans.""" |
| 438 |
|
| 439 |
self.check_markdown( |
| 440 |
r''' |
| 441 |
```{.python #id linenums="2"} |
| 442 |
import test |
| 443 |
``` |
| 444 |
''', |
| 445 |
r''' |
| 446 |
<div id="id" class="highlight"><pre><span></span><code><a id="__codelineno-id-2" name="__codelineno-id-2"></a><a href="#__codelineno-id-2"><span class="linenos" data-linenos="2 "></span></a><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 447 |
</code></pre></div> |
| 448 |
''', # noqa: E501 |
| 449 |
True |
| 450 |
) |
| 451 |
|
| 452 |
|
| 453 |
class TestHighlightAnchorLinenumsPymdownsTable(util.MdCase): |
| 454 |
"""Test highlight line wraps.""" |
| 455 |
|
| 456 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 457 |
extension_configs = { |
| 458 |
'pymdownx.highlight': { |
| 459 |
'anchor_linenums': True, |
| 460 |
'linenums_style': 'table' |
| 461 |
} |
| 462 |
} |
| 463 |
|
| 464 |
def test_linespans(self): |
| 465 |
"""Test wrapping a line in line spans.""" |
| 466 |
|
| 467 |
self.check_markdown( |
| 468 |
r''' |
| 469 |
```python linenums="2" |
| 470 |
import test |
| 471 |
``` |
| 472 |
''', |
| 473 |
r''' |
| 474 |
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-2">2</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-0-2" name="__codelineno-0-2"></a><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 475 |
</code></pre></div></td></tr></table></div> |
| 476 |
''', # noqa: E501 |
| 477 |
True |
| 478 |
) |
| 479 |
|
| 480 |
|
| 481 |
class TestHighlightAnchorLinenumNameInline(util.MdCase): |
| 482 |
"""Test highlight line wraps.""" |
| 483 |
|
| 484 |
extension = ['pymdownx.highlight', 'pymdownx.superfences'] |
| 485 |
extension_configs = { |
| 486 |
'pymdownx.highlight': { |
| 487 |
'anchor_linenums': True, |
| 488 |
'line_anchors': '__my_span', |
| 489 |
'linenums_style': 'inline' |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
def test_linespans(self): |
| 494 |
"""Test wrapping a line in line spans.""" |
| 495 |
|
| 496 |
self.check_markdown( |
| 497 |
r''' |
| 498 |
```python linenums="2" |
| 499 |
import test |
| 500 |
``` |
| 501 |
''', |
| 502 |
r''' |
| 503 |
<div class="highlight"><pre><span></span><code><a id="__my_span-0-2" name="__my_span-0-2"></a><a href="#__my_span-0-2"><span class="linenos">2</span></a><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 504 |
</code></pre></div> |
| 505 |
''', # noqa: E501 |
| 506 |
True |
| 507 |
) |
| 508 |
|
| 509 |
|
| 510 |
class TestHighlightLines(util.MdCase): |
| 511 |
"""Test line highlighting.""" |
| 512 |
|
| 513 |
extension = ['pymdownx.superfences'] |
| 514 |
extension_configs = {} |
| 515 |
|
| 516 |
def test_highlight_range(self): |
| 517 |
"""Test highlight ranges.""" |
| 518 |
|
| 519 |
self.check_markdown( |
| 520 |
r''' |
| 521 |
```py3 hl_lines="1-2 5 7-8" |
| 522 |
import foo |
| 523 |
import boo.baz |
| 524 |
import foo.bar.baz |
| 525 |
|
| 526 |
class Foo: |
| 527 |
def __init__(self): |
| 528 |
self.foo = None |
| 529 |
self.bar = None |
| 530 |
self.baz = None |
| 531 |
``` |
| 532 |
''', |
| 533 |
''' |
| 534 |
<div class="highlight"><pre><span></span><code><span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">foo</span> |
| 535 |
</span><span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">boo.baz</span> |
| 536 |
</span><span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar.baz</span> |
| 537 |
|
| 538 |
<span class="hll"><span class="k">class</span><span class="w"> </span><span class="nc">Foo</span><span class="p">:</span> |
| 539 |
</span> <span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
| 540 |
<span class="hll"> <span class="bp">self</span><span class="o">.</span><span class="n">foo</span> <span class="o">=</span> <span class="kc">None</span> |
| 541 |
</span><span class="hll"> <span class="bp">self</span><span class="o">.</span><span class="n">bar</span> <span class="o">=</span> <span class="kc">None</span> |
| 542 |
</span> <span class="bp">self</span><span class="o">.</span><span class="n">baz</span> <span class="o">=</span> <span class="kc">None</span> |
| 543 |
</code></pre></div> |
| 544 |
''', # noqa: E501 |
| 545 |
True |
| 546 |
) |
| 547 |
|
| 548 |
def test_highlight_out_of_range(self): |
| 549 |
"""Test highlight ranges.""" |
| 550 |
|
| 551 |
self.check_markdown( |
| 552 |
r''' |
| 553 |
```py3 hl_lines="0 10" |
| 554 |
import foo |
| 555 |
import boo.baz |
| 556 |
import foo.bar.baz |
| 557 |
|
| 558 |
class Foo: |
| 559 |
def __init__(self): |
| 560 |
self.foo = None |
| 561 |
self.bar = None |
| 562 |
self.baz = None |
| 563 |
``` |
| 564 |
''', |
| 565 |
''' |
| 566 |
<div class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">foo</span> |
| 567 |
<span class="kn">import</span><span class="w"> </span><span class="nn">boo.baz</span> |
| 568 |
<span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar.baz</span> |
| 569 |
|
| 570 |
<span class="k">class</span><span class="w"> </span><span class="nc">Foo</span><span class="p">:</span> |
| 571 |
<span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
| 572 |
<span class="bp">self</span><span class="o">.</span><span class="n">foo</span> <span class="o">=</span> <span class="kc">None</span> |
| 573 |
<span class="bp">self</span><span class="o">.</span><span class="n">bar</span> <span class="o">=</span> <span class="kc">None</span> |
| 574 |
<span class="bp">self</span><span class="o">.</span><span class="n">baz</span> <span class="o">=</span> <span class="kc">None</span> |
| 575 |
</code></pre></div> |
| 576 |
''', # noqa: E501 |
| 577 |
True |
| 578 |
) |
| 579 |
|
| 580 |
def test_highlight_in_range_only(self): |
| 581 |
"""Test highlight ranges.""" |
| 582 |
|
| 583 |
self.check_markdown( |
| 584 |
r''' |
| 585 |
```py3 hl_lines="0-10" |
| 586 |
import foo |
| 587 |
import boo.baz |
| 588 |
import foo.bar.baz |
| 589 |
|
| 590 |
class Foo: |
| 591 |
def __init__(self): |
| 592 |
self.foo = None |
| 593 |
self.bar = None |
| 594 |
self.baz = None |
| 595 |
``` |
| 596 |
''', |
| 597 |
''' |
| 598 |
<div class="highlight"><pre><span></span><code><span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">foo</span> |
| 599 |
</span><span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">boo.baz</span> |
| 600 |
</span><span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar.baz</span> |
| 601 |
</span><span class="hll"> |
| 602 |
</span><span class="hll"><span class="k">class</span><span class="w"> </span><span class="nc">Foo</span><span class="p">:</span> |
| 603 |
</span><span class="hll"> <span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
| 604 |
</span><span class="hll"> <span class="bp">self</span><span class="o">.</span><span class="n">foo</span> <span class="o">=</span> <span class="kc">None</span> |
| 605 |
</span><span class="hll"> <span class="bp">self</span><span class="o">.</span><span class="n">bar</span> <span class="o">=</span> <span class="kc">None</span> |
| 606 |
</span><span class="hll"> <span class="bp">self</span><span class="o">.</span><span class="n">baz</span> <span class="o">=</span> <span class="kc">None</span> |
| 607 |
</span></code></pre></div> |
| 608 |
''', # noqa: E501 |
| 609 |
True |
| 610 |
) |
| 611 |
|
| 612 |
def test_nonword_boundary_language(self): |
| 613 |
"""Test language with non-word boundary.""" |
| 614 |
|
| 615 |
self.check_markdown( |
| 616 |
""" |
| 617 |
```c++ hl_lines="1" |
| 618 |
#include <iostream> |
| 619 |
``` |
| 620 |
""", |
| 621 |
""" |
| 622 |
<div class="highlight"><pre><span></span><code><span class="hll"><span class="cp">#include</span><span class="w"> </span><span class="cpf"><iostream></span> |
| 623 |
</span></code></pre></div> |
| 624 |
""", # noqa: E501 |
| 625 |
True |
| 626 |
) |
| 627 |
|
| 628 |
def test_omitted_language(self): |
| 629 |
"""Test when language is omitted.""" |
| 630 |
|
| 631 |
self.check_markdown( |
| 632 |
""" |
| 633 |
```hl_lines="1" |
| 634 |
some |
| 635 |
code |
| 636 |
``` |
| 637 |
""", |
| 638 |
""" |
| 639 |
<div class="highlight"><pre><span></span><code><span class="hll">some |
| 640 |
</span>code |
| 641 |
</code></pre></div> |
| 642 |
""", |
| 643 |
True |
| 644 |
) |
| 645 |
|
| 646 |
|
| 647 |
class TestSuperFencesClassesIds(util.MdCase): |
| 648 |
"""Test classes and ids without attribute lists.""" |
| 649 |
|
| 650 |
extension = ['pymdownx.superfences'] |
| 651 |
extension_configs = {} |
| 652 |
|
| 653 |
def test_classes(self): |
| 654 |
"""Test extra classes.""" |
| 655 |
|
| 656 |
self.check_markdown( |
| 657 |
r''' |
| 658 |
```{.python .more} |
| 659 |
import test |
| 660 |
``` |
| 661 |
''', |
| 662 |
r''' |
| 663 |
<div class="more highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 664 |
</code></pre></div> |
| 665 |
''', # noqa: E501 |
| 666 |
True |
| 667 |
) |
| 668 |
|
| 669 |
def test_id(self): |
| 670 |
"""Test extra id.""" |
| 671 |
|
| 672 |
self.check_markdown( |
| 673 |
r''' |
| 674 |
```{.python #id} |
| 675 |
import test |
| 676 |
``` |
| 677 |
''', |
| 678 |
r''' |
| 679 |
<div id="id" class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 680 |
</code></pre></div> |
| 681 |
''', # noqa: E501 |
| 682 |
True |
| 683 |
) |
| 684 |
|
| 685 |
def test_attr(self): |
| 686 |
"""Test extra attributes.""" |
| 687 |
|
| 688 |
self.check_markdown( |
| 689 |
r''' |
| 690 |
```{.python #id attr="test"} |
| 691 |
import test |
| 692 |
``` |
| 693 |
''', |
| 694 |
r''' |
| 695 |
<div id="id" class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 696 |
</code></pre></div> |
| 697 |
''', # noqa: E501 |
| 698 |
True |
| 699 |
) |
| 700 |
|
| 701 |
def test_attrs_alternate_form(self): |
| 702 |
"""Test attributes with new alternate form.""" |
| 703 |
|
| 704 |
self.check_markdown( |
| 705 |
r''' |
| 706 |
```python {.test .class #class} |
| 707 |
import test |
| 708 |
``` |
| 709 |
''', |
| 710 |
r''' |
| 711 |
<div id="class" class="test class highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 712 |
</code></pre></div> |
| 713 |
''', # noqa: E501 |
| 714 |
True |
| 715 |
) |
| 716 |
|
| 717 |
def test_issue_2479(self): |
| 718 |
"""Test issue #2479.""" |
| 719 |
|
| 720 |
self.check_markdown( |
| 721 |
"""```test_test_test_test_test_test_test_test``` test test.""", |
| 722 |
""" |
| 723 |
<p><code>test_test_test_test_test_test_test_test</code> test test.</p> |
| 724 |
""", |
| 725 |
True |
| 726 |
) |
| 727 |
|
| 728 |
|
| 729 |
class TestSuperFencesClassesIdsAttrList(util.MdCase): |
| 730 |
"""Test fence ids and classes with attribute lists.""" |
| 731 |
|
| 732 |
extension = ['pymdownx.superfences', 'markdown.extensions.attr_list'] |
| 733 |
extension_configs = {} |
| 734 |
|
| 735 |
def test_attribute_lists_with_braces(self): |
| 736 |
"""Test attribute lists with braces.""" |
| 737 |
|
| 738 |
self.check_markdown( |
| 739 |
R''' |
| 740 |
``` { .c data-copy="int main() { return 0; }" } |
| 741 |
Try copying me for some C code |
| 742 |
``` |
| 743 |
''', |
| 744 |
R''' |
| 745 |
<div class="highlight" data-copy="int main() { return 0; }"><pre><span></span><code><span class="n">Try</span><span class="w"> </span><span class="n">copying</span><span class="w"> </span><span class="n">me</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">some</span><span class="w"> </span><span class="n">C</span><span class="w"> </span><span class="n">code</span> |
| 746 |
</code></pre></div> |
| 747 |
''', # noqa: E501 |
| 748 |
True |
| 749 |
) |
| 750 |
|
| 751 |
def test_classes(self): |
| 752 |
"""Test extra classes.""" |
| 753 |
|
| 754 |
self.check_markdown( |
| 755 |
r''' |
| 756 |
```{.python .more} |
| 757 |
import test |
| 758 |
``` |
| 759 |
''', |
| 760 |
r''' |
| 761 |
<div class="more highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 762 |
</code></pre></div> |
| 763 |
''', # noqa: E501 |
| 764 |
True |
| 765 |
) |
| 766 |
|
| 767 |
def test_id(self): |
| 768 |
"""Test extra id.""" |
| 769 |
|
| 770 |
self.check_markdown( |
| 771 |
r''' |
| 772 |
```{.python #id} |
| 773 |
import test |
| 774 |
``` |
| 775 |
''', |
| 776 |
r''' |
| 777 |
<div id="id" class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 778 |
</code></pre></div> |
| 779 |
''', # noqa: E501 |
| 780 |
True |
| 781 |
) |
| 782 |
|
| 783 |
def test_bad_attr(self): |
| 784 |
"""Test bad attribute.""" |
| 785 |
|
| 786 |
self.check_markdown( |
| 787 |
r''' |
| 788 |
```{.python #id attr="test"} |
| 789 |
import test |
| 790 |
``` |
| 791 |
''', |
| 792 |
r''' |
| 793 |
<div id="id" class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 794 |
</code></pre></div> |
| 795 |
''', # noqa: E501 |
| 796 |
True |
| 797 |
) |
| 798 |
|
| 799 |
def test_data_attr(self): |
| 800 |
"""Test data attributes.""" |
| 801 |
|
| 802 |
self.check_markdown( |
| 803 |
r''' |
| 804 |
```{.python #id data-attr="test"} |
| 805 |
import test |
| 806 |
``` |
| 807 |
''', |
| 808 |
r''' |
| 809 |
<div id="id" class="highlight" data-attr="test"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 810 |
</code></pre></div> |
| 811 |
''', # noqa: E501 |
| 812 |
True |
| 813 |
) |
| 814 |
|
| 815 |
def test_data_attr_linenums(self): |
| 816 |
"""Test data attributes with line numbers enabled.""" |
| 817 |
|
| 818 |
self.check_markdown( |
| 819 |
r''' |
| 820 |
```{.python #id data-attr="test" linenums="1"} |
| 821 |
import test |
| 822 |
``` |
| 823 |
''', |
| 824 |
r''' |
| 825 |
<div id="id" class="highlight" data-attr="test"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 826 |
</code></pre></div></td></tr></table></div> |
| 827 |
''', # noqa: E501 |
| 828 |
True |
| 829 |
) |
| 830 |
|
| 831 |
def test_attrs_alternate_form(self): |
| 832 |
"""Test attributes with new alternate form.""" |
| 833 |
|
| 834 |
self.check_markdown( |
| 835 |
r''' |
| 836 |
```python {.test .class #id data-attr="test" linenums="1"} |
| 837 |
import test |
| 838 |
``` |
| 839 |
''', |
| 840 |
r''' |
| 841 |
<div id="id" class="test class highlight" data-attr="test"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 842 |
</code></pre></div></td></tr></table></div> |
| 843 |
''', # noqa: E501 |
| 844 |
True |
| 845 |
) |
| 846 |
|
| 847 |
|
| 848 |
class TestSuperFencesClassesIdsAttrListNoPygments(util.MdCase): |
| 849 |
"""Test fence ids and classes with attribute lists and with no Pygments.""" |
| 850 |
|
| 851 |
extension = ['pymdownx.highlight', 'pymdownx.superfences', 'markdown.extensions.attr_list'] |
| 852 |
extension_configs = { |
| 853 |
"pymdownx.highlight": { |
| 854 |
"use_pygments": False |
| 855 |
} |
| 856 |
} |
| 857 |
|
| 858 |
def test_classes(self): |
| 859 |
"""Test extra classes.""" |
| 860 |
|
| 861 |
self.check_markdown( |
| 862 |
r''' |
| 863 |
```{.python .more} |
| 864 |
import test |
| 865 |
``` |
| 866 |
''', |
| 867 |
r''' |
| 868 |
<pre class="highlight"><code class="language-python more">import test</code></pre> |
| 869 |
''', |
| 870 |
True |
| 871 |
) |
| 872 |
|
| 873 |
def test_id(self): |
| 874 |
"""Test extra id.""" |
| 875 |
|
| 876 |
self.check_markdown( |
| 877 |
r''' |
| 878 |
```{.python #id} |
| 879 |
import test |
| 880 |
``` |
| 881 |
''', |
| 882 |
r''' |
| 883 |
<pre class="highlight"><code id="id" class="language-python">import test</code></pre> |
| 884 |
''', |
| 885 |
True |
| 886 |
) |
| 887 |
|
| 888 |
def test_attr(self): |
| 889 |
"""Test extra attributes.""" |
| 890 |
|
| 891 |
self.check_markdown( |
| 892 |
r''' |
| 893 |
```{.python #id attr="test"} |
| 894 |
import test |
| 895 |
``` |
| 896 |
''', |
| 897 |
r''' |
| 898 |
<pre class="highlight"><code id="id" class="language-python" attr="test">import test</code></pre> |
| 899 |
''', |
| 900 |
True |
| 901 |
) |
| 902 |
|
| 903 |
|
| 904 |
class TestSuperFencesClassesIdsAttrListNoPygmentsOnPre(util.MdCase): |
| 905 |
"""Test fence ids and classes with attribute lists and with no Pygments and classes and ids on pre.""" |
| 906 |
|
| 907 |
extension = ['pymdownx.highlight', 'pymdownx.superfences', 'markdown.extensions.attr_list'] |
| 908 |
extension_configs = { |
| 909 |
"pymdownx.highlight": { |
| 910 |
"use_pygments": False, |
| 911 |
"code_attr_on_pre": True |
| 912 |
} |
| 913 |
} |
| 914 |
|
| 915 |
def test_classes(self): |
| 916 |
"""Test extra classes.""" |
| 917 |
|
| 918 |
self.check_markdown( |
| 919 |
r''' |
| 920 |
```{.python .more} |
| 921 |
import test |
| 922 |
``` |
| 923 |
''', |
| 924 |
r''' |
| 925 |
<pre class="language-python highlight more"><code>import test</code></pre> |
| 926 |
''', |
| 927 |
True |
| 928 |
) |
| 929 |
|
| 930 |
def test_id(self): |
| 931 |
"""Test extra id.""" |
| 932 |
|
| 933 |
self.check_markdown( |
| 934 |
r''' |
| 935 |
```{.python #id} |
| 936 |
import test |
| 937 |
``` |
| 938 |
''', |
| 939 |
r''' |
| 940 |
<pre id="id" class="language-python highlight"><code>import test</code></pre> |
| 941 |
''', |
| 942 |
True |
| 943 |
) |
| 944 |
|
| 945 |
def test_attr(self): |
| 946 |
"""Test extra attributes.""" |
| 947 |
|
| 948 |
self.check_markdown( |
| 949 |
r''' |
| 950 |
```{.python #id attr="test"} |
| 951 |
import test |
| 952 |
``` |
| 953 |
''', |
| 954 |
r''' |
| 955 |
<pre id="id" class="language-python highlight" attr="test"><code>import test</code></pre> |
| 956 |
''', |
| 957 |
True |
| 958 |
) |
| 959 |
|
| 960 |
|
| 961 |
class TestSuperFencesBad(util.MdCase): |
| 962 |
"""Test bad options.""" |
| 963 |
|
| 964 |
extension = ['pymdownx.superfences'] |
| 965 |
extension_configs = {} |
| 966 |
|
| 967 |
def test_bad_options(self): |
| 968 |
"""Test bad options.""" |
| 969 |
|
| 970 |
self.check_markdown( |
| 971 |
r''' |
| 972 |
```python option="bad" |
| 973 |
import test |
| 974 |
``` |
| 975 |
''', |
| 976 |
r''' |
| 977 |
<p><code>python option="bad" |
| 978 |
import test</code></p> |
| 979 |
''', |
| 980 |
True |
| 981 |
) |
| 982 |
|
| 983 |
def test_bad_option_value(self): |
| 984 |
"""Test bad option values.""" |
| 985 |
|
| 986 |
self.check_markdown( |
| 987 |
r''' |
| 988 |
```python hl_lines="unexpected 3" linenums="1" |
| 989 |
"""Some file.""" |
| 990 |
import foo.bar |
| 991 |
import boo.baz |
| 992 |
import foo.bar.baz |
| 993 |
``` |
| 994 |
''', |
| 995 |
r''' |
| 996 |
<p><code>python hl_lines="unexpected 3" linenums="1" |
| 997 |
"""Some file.""" |
| 998 |
import foo.bar |
| 999 |
import boo.baz |
| 1000 |
import foo.bar.baz</code></p> |
| 1001 |
''', |
| 1002 |
True |
| 1003 |
) |
| 1004 |
|
| 1005 |
|
| 1006 |
class TestSuperFencesCustom(util.MdCase): |
| 1007 |
"""Test custom validator and format.""" |
| 1008 |
|
| 1009 |
extension = ['pymdownx.superfences', 'attr_list'] |
| 1010 |
extension_configs = { |
| 1011 |
'pymdownx.superfences': { |
| 1012 |
'custom_fences': [ |
| 1013 |
{ |
| 1014 |
'name': 'test', |
| 1015 |
'class': 'test', |
| 1016 |
'format': custom_format, |
| 1017 |
'validator': custom_validator |
| 1018 |
} |
| 1019 |
] |
| 1020 |
} |
| 1021 |
} |
| 1022 |
|
| 1023 |
def test_failure(self): |
| 1024 |
""" |
| 1025 |
Test failure of custom fence. |
| 1026 |
|
| 1027 |
Fence failed, gracefully continue with any other fences that can capture this. |
| 1028 |
""" |
| 1029 |
|
| 1030 |
self.check_markdown( |
| 1031 |
r''' |
| 1032 |
```test |
| 1033 |
test |
| 1034 |
``` |
| 1035 |
''', |
| 1036 |
r''' |
| 1037 |
<div class="highlight"><pre><span></span><code>test |
| 1038 |
</code></pre></div> |
| 1039 |
''', |
| 1040 |
True |
| 1041 |
) |
| 1042 |
|
| 1043 |
def test_bad_options(self): |
| 1044 |
"""Test bad option.""" |
| 1045 |
|
| 1046 |
self.check_markdown( |
| 1047 |
r''' |
| 1048 |
```test bad="bad" |
| 1049 |
test |
| 1050 |
``` |
| 1051 |
''', |
| 1052 |
r''' |
| 1053 |
<p><code>test bad="bad" |
| 1054 |
test</code></p> |
| 1055 |
''', |
| 1056 |
True |
| 1057 |
) |
| 1058 |
|
| 1059 |
def test_bad_option_value(self): |
| 1060 |
"""Test option with bad value.""" |
| 1061 |
|
| 1062 |
self.check_markdown( |
| 1063 |
r''' |
| 1064 |
```test opt="B" |
| 1065 |
test |
| 1066 |
``` |
| 1067 |
''', |
| 1068 |
r''' |
| 1069 |
<p><code>test opt="B" |
| 1070 |
test</code></p> |
| 1071 |
''', |
| 1072 |
True |
| 1073 |
) |
| 1074 |
|
| 1075 |
def test_bad_option_no_value(self): |
| 1076 |
"""Test option with no value.""" |
| 1077 |
|
| 1078 |
self.check_markdown( |
| 1079 |
r''' |
| 1080 |
```test opt |
| 1081 |
test |
| 1082 |
``` |
| 1083 |
''', |
| 1084 |
r''' |
| 1085 |
<p><code>test opt |
| 1086 |
test</code></p> |
| 1087 |
''', |
| 1088 |
True |
| 1089 |
) |
| 1090 |
|
| 1091 |
def test_custom_options(self): |
| 1092 |
"""Test option with correct value.""" |
| 1093 |
|
| 1094 |
self.check_markdown( |
| 1095 |
r''' |
| 1096 |
```test opt="A" |
| 1097 |
test |
| 1098 |
``` |
| 1099 |
''', |
| 1100 |
r''' |
| 1101 |
<div lang="test" class_name="class-test", option="A">test</div> |
| 1102 |
''', |
| 1103 |
True |
| 1104 |
) |
| 1105 |
|
| 1106 |
def test_custom_options_attr_list(self): |
| 1107 |
"""Test option with correct value.""" |
| 1108 |
|
| 1109 |
self.check_markdown( |
| 1110 |
r''' |
| 1111 |
```test {opt="A"} |
| 1112 |
test |
| 1113 |
``` |
| 1114 |
''', |
| 1115 |
r''' |
| 1116 |
<div lang="test" class_name="class-test", option="A">test</div> |
| 1117 |
''', |
| 1118 |
True |
| 1119 |
) |
| 1120 |
|
| 1121 |
|
| 1122 |
class TestSuperFencesCustomException(util.MdCase): |
| 1123 |
"""Test custom validator and format.""" |
| 1124 |
|
| 1125 |
extension = ['pymdownx.superfences'] |
| 1126 |
extension_configs = { |
| 1127 |
'pymdownx.superfences': { |
| 1128 |
'custom_fences': [ |
| 1129 |
{ |
| 1130 |
'name': 'test', |
| 1131 |
'class': 'test', |
| 1132 |
'format': custom_format, |
| 1133 |
'validator': custom_validator_except |
| 1134 |
} |
| 1135 |
] |
| 1136 |
} |
| 1137 |
} |
| 1138 |
|
| 1139 |
def test_custom_fail_exception(self): |
| 1140 |
"""Test custom fences forced exception.""" |
| 1141 |
|
| 1142 |
with self.assertRaises(SuperFencesException): |
| 1143 |
self.check_markdown( |
| 1144 |
r''' |
| 1145 |
```test |
| 1146 |
test |
| 1147 |
``` |
| 1148 |
''', |
| 1149 |
'', |
| 1150 |
True |
| 1151 |
) |
| 1152 |
|
| 1153 |
|
| 1154 |
class TestSuperFencesCustomExceptionAttrList(util.MdCase): |
| 1155 |
"""Test custom validator and format with attribute lists.""" |
| 1156 |
|
| 1157 |
extension = ['pymdownx.superfences', 'attr_list'] |
| 1158 |
extension_configs = { |
| 1159 |
'pymdownx.superfences': { |
| 1160 |
'custom_fences': [ |
| 1161 |
{ |
| 1162 |
'name': 'test', |
| 1163 |
'class': 'test', |
| 1164 |
'format': custom_format, |
| 1165 |
'validator': custom_validator_except |
| 1166 |
} |
| 1167 |
] |
| 1168 |
} |
| 1169 |
} |
| 1170 |
|
| 1171 |
def test_custom_fail_exception(self): |
| 1172 |
"""Test custom fences forced exception with attribute lists.""" |
| 1173 |
|
| 1174 |
with self.assertRaises(SuperFencesException): |
| 1175 |
self.check_markdown( |
| 1176 |
r''' |
| 1177 |
```{.test} |
| 1178 |
test |
| 1179 |
``` |
| 1180 |
''', |
| 1181 |
'', |
| 1182 |
True |
| 1183 |
) |
| 1184 |
|
| 1185 |
|
| 1186 |
class TestSuperFencesCustomDefaultValidator(util.MdCase): |
| 1187 |
"""Test custom format with default validator.""" |
| 1188 |
|
| 1189 |
extension = ['pymdownx.superfences', 'markdown.extensions.attr_list'] |
| 1190 |
extension_configs = { |
| 1191 |
'pymdownx.superfences': { |
| 1192 |
'custom_fences': [ |
| 1193 |
{ |
| 1194 |
'name': 'test', |
| 1195 |
'class': 'test', |
| 1196 |
'format': superfences.fence_div_format, |
| 1197 |
'validator': superfences.default_validator |
| 1198 |
} |
| 1199 |
] |
| 1200 |
} |
| 1201 |
} |
| 1202 |
|
| 1203 |
def test_default_validator(self): |
| 1204 |
"""Test default validator.""" |
| 1205 |
|
| 1206 |
self.check_markdown( |
| 1207 |
r''' |
| 1208 |
```{.test opt="A"} |
| 1209 |
test |
| 1210 |
``` |
| 1211 |
''', |
| 1212 |
r''' |
| 1213 |
<div class="test" opt="A">test</div> |
| 1214 |
''', |
| 1215 |
True |
| 1216 |
) |
| 1217 |
|
| 1218 |
|
| 1219 |
class TestSuperFencesCustomArithmatex(util.MdCase): |
| 1220 |
"""Test custom Arithmatex format.""" |
| 1221 |
|
| 1222 |
extension = ['pymdownx.superfences'] |
| 1223 |
extension_configs = { |
| 1224 |
'pymdownx.superfences': { |
| 1225 |
'custom_fences': [ |
| 1226 |
{ |
| 1227 |
'name': 'math', |
| 1228 |
'class': 'arithmatex', |
| 1229 |
'format': arithmatex.arithmatex_fenced_format(mode="mathjax") |
| 1230 |
} |
| 1231 |
] |
| 1232 |
} |
| 1233 |
} |
| 1234 |
|
| 1235 |
def test_arithmatex(self): |
| 1236 |
"""Test Arithmatex formatter without preview.""" |
| 1237 |
|
| 1238 |
self.check_markdown( |
| 1239 |
r''' |
| 1240 |
```math |
| 1241 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1242 |
``` |
| 1243 |
''', |
| 1244 |
r''' |
| 1245 |
<div class="arithmatex"> |
| 1246 |
<script type="math/tex; mode=display"> |
| 1247 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1248 |
</script> |
| 1249 |
</div> |
| 1250 |
''', |
| 1251 |
True |
| 1252 |
) |
| 1253 |
|
| 1254 |
|
| 1255 |
class TestSuperFencesCustomLegacyArithmatex(util.MdCase): |
| 1256 |
"""Test custom Arithmatex format.""" |
| 1257 |
|
| 1258 |
extension = ['pymdownx.superfences'] |
| 1259 |
extension_configs = { |
| 1260 |
'pymdownx.superfences': { |
| 1261 |
'custom_fences': [ |
| 1262 |
{ |
| 1263 |
'name': 'math', |
| 1264 |
'class': 'arithmatex', |
| 1265 |
'format': arithmatex.fence_mathjax_format |
| 1266 |
} |
| 1267 |
] |
| 1268 |
} |
| 1269 |
} |
| 1270 |
|
| 1271 |
def test_legacy_arithmatex(self): |
| 1272 |
"""Test Arithmatex formatter without preview.""" |
| 1273 |
|
| 1274 |
with warnings.catch_warnings(record=True) as w: |
| 1275 |
self.check_markdown( |
| 1276 |
r''' |
| 1277 |
```math |
| 1278 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1279 |
``` |
| 1280 |
''', |
| 1281 |
r''' |
| 1282 |
<div class="arithmatex"> |
| 1283 |
<script type="math/tex; mode=display"> |
| 1284 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1285 |
</script> |
| 1286 |
</div> |
| 1287 |
''', |
| 1288 |
True |
| 1289 |
) |
| 1290 |
|
| 1291 |
self.assertTrue(len(w) == 1) |
| 1292 |
self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) |
| 1293 |
|
| 1294 |
|
| 1295 |
class TestSuperFencesCustomArithmatexPreview(util.MdCase): |
| 1296 |
"""Test custom Arithmatex preview format.""" |
| 1297 |
|
| 1298 |
extension = ['pymdownx.superfences'] |
| 1299 |
extension_configs = { |
| 1300 |
'pymdownx.superfences': { |
| 1301 |
'custom_fences': [ |
| 1302 |
{ |
| 1303 |
'name': 'math', |
| 1304 |
'class': 'arithmatex', |
| 1305 |
'format': arithmatex.arithmatex_fenced_format(mode='mathjax', preview=True) |
| 1306 |
} |
| 1307 |
] |
| 1308 |
} |
| 1309 |
} |
| 1310 |
|
| 1311 |
def test_arithmatex_preview(self): |
| 1312 |
"""Test Arithmatex formatter with preview.""" |
| 1313 |
|
| 1314 |
self.check_markdown( |
| 1315 |
r''' |
| 1316 |
```math |
| 1317 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1318 |
``` |
| 1319 |
''', |
| 1320 |
r''' |
| 1321 |
<div class="arithmatex"> |
| 1322 |
<div class="MathJax_Preview"> |
| 1323 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1324 |
</div> |
| 1325 |
<script type="math/tex; mode=display"> |
| 1326 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1327 |
</script> |
| 1328 |
</div> |
| 1329 |
''', |
| 1330 |
True |
| 1331 |
) |
| 1332 |
|
| 1333 |
|
| 1334 |
class TestSuperFencesCustomLegacyArithmatexPreview(util.MdCase): |
| 1335 |
"""Test custom Arithmatex preview format.""" |
| 1336 |
|
| 1337 |
extension = ['pymdownx.superfences'] |
| 1338 |
extension_configs = { |
| 1339 |
'pymdownx.superfences': { |
| 1340 |
'custom_fences': [ |
| 1341 |
{ |
| 1342 |
'name': 'math', |
| 1343 |
'class': 'arithmatex', |
| 1344 |
'format': arithmatex.fence_mathjax_preview_format |
| 1345 |
} |
| 1346 |
] |
| 1347 |
} |
| 1348 |
} |
| 1349 |
|
| 1350 |
def test_legacy_arithmatex_preview(self): |
| 1351 |
"""Test Arithmatex formatter with preview.""" |
| 1352 |
|
| 1353 |
with warnings.catch_warnings(record=True) as w: |
| 1354 |
self.check_markdown( |
| 1355 |
r''' |
| 1356 |
```math |
| 1357 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1358 |
``` |
| 1359 |
''', |
| 1360 |
r''' |
| 1361 |
<div class="arithmatex"> |
| 1362 |
<div class="MathJax_Preview"> |
| 1363 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1364 |
</div> |
| 1365 |
<script type="math/tex; mode=display"> |
| 1366 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1367 |
</script> |
| 1368 |
</div> |
| 1369 |
''', |
| 1370 |
True |
| 1371 |
) |
| 1372 |
|
| 1373 |
self.assertTrue(len(w) == 1) |
| 1374 |
self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) |
| 1375 |
|
| 1376 |
|
| 1377 |
class TestSuperFencesCustomArithmatexGeneric(util.MdCase): |
| 1378 |
"""Test custom Arithmatex generic format.""" |
| 1379 |
|
| 1380 |
extension = ['pymdownx.superfences'] |
| 1381 |
extension_configs = { |
| 1382 |
'pymdownx.superfences': { |
| 1383 |
'custom_fences': [ |
| 1384 |
{ |
| 1385 |
'name': 'math', |
| 1386 |
'class': 'arithmatex', |
| 1387 |
'format': arithmatex.arithmatex_fenced_format(mode="generic") |
| 1388 |
} |
| 1389 |
] |
| 1390 |
} |
| 1391 |
} |
| 1392 |
|
| 1393 |
def test_arithmatex_generic(self): |
| 1394 |
"""Test Arithmatex generic formatter.""" |
| 1395 |
|
| 1396 |
self.check_markdown( |
| 1397 |
r''' |
| 1398 |
```math |
| 1399 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1400 |
``` |
| 1401 |
''', |
| 1402 |
r''' |
| 1403 |
<div class="arithmatex">\[ |
| 1404 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1405 |
\]</div> |
| 1406 |
''', |
| 1407 |
True |
| 1408 |
) |
| 1409 |
|
| 1410 |
|
| 1411 |
class TestSuperFencesCustomLegacyArithmatexGeneric(util.MdCase): |
| 1412 |
"""Test custom Arithmatex generic format.""" |
| 1413 |
|
| 1414 |
extension = ['pymdownx.superfences'] |
| 1415 |
extension_configs = { |
| 1416 |
'pymdownx.superfences': { |
| 1417 |
'custom_fences': [ |
| 1418 |
{ |
| 1419 |
'name': 'math', |
| 1420 |
'class': 'arithmatex', |
| 1421 |
'format': arithmatex.fence_generic_format |
| 1422 |
} |
| 1423 |
] |
| 1424 |
} |
| 1425 |
} |
| 1426 |
|
| 1427 |
def test_legacy_arithmatex_generic(self): |
| 1428 |
"""Test Arithmatex generic formatter.""" |
| 1429 |
|
| 1430 |
with warnings.catch_warnings(record=True) as w: |
| 1431 |
self.check_markdown( |
| 1432 |
r''' |
| 1433 |
```math |
| 1434 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1435 |
``` |
| 1436 |
''', |
| 1437 |
r''' |
| 1438 |
<div class="arithmatex">\[ |
| 1439 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1440 |
\]</div> |
| 1441 |
''', |
| 1442 |
True |
| 1443 |
) |
| 1444 |
|
| 1445 |
self.assertTrue(len(w) == 1) |
| 1446 |
self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) |
| 1447 |
|
| 1448 |
|
| 1449 |
class TestSuperFencesCustomDefault(util.MdCase): |
| 1450 |
"""Test overriding the default format.""" |
| 1451 |
|
| 1452 |
extension = ['pymdownx.superfences'] |
| 1453 |
extension_configs = { |
| 1454 |
'pymdownx.superfences': { |
| 1455 |
'custom_fences': [ |
| 1456 |
{ |
| 1457 |
'name': '*', |
| 1458 |
'class': '', |
| 1459 |
'format': default_format |
| 1460 |
}, |
| 1461 |
{ |
| 1462 |
'name': 'math', |
| 1463 |
'class': 'arithmatex', |
| 1464 |
'format': arithmatex.arithmatex_fenced_format(mode="generic") |
| 1465 |
} |
| 1466 |
] |
| 1467 |
} |
| 1468 |
} |
| 1469 |
|
| 1470 |
def test_default_override(self): |
| 1471 |
"""Test default override.""" |
| 1472 |
|
| 1473 |
self.check_markdown( |
| 1474 |
r''' |
| 1475 |
```math |
| 1476 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1477 |
``` |
| 1478 |
|
| 1479 |
```python |
| 1480 |
test |
| 1481 |
``` |
| 1482 |
''', |
| 1483 |
r''' |
| 1484 |
<div class="arithmatex">\[ |
| 1485 |
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j |
| 1486 |
\]</div> |
| 1487 |
<p><custom lang="python" class_name="class-">test</custom></p> |
| 1488 |
''', |
| 1489 |
True |
| 1490 |
) |
| 1491 |
|
| 1492 |
|
| 1493 |
class TestSuperFencesCustomBroken(util.MdCase): |
| 1494 |
"""Test custom formatter that is broken.""" |
| 1495 |
|
| 1496 |
extension = ['pymdownx.superfences'] |
| 1497 |
extension_configs = { |
| 1498 |
'pymdownx.superfences': { |
| 1499 |
'custom_fences': [ |
| 1500 |
{ |
| 1501 |
'name': 'test', |
| 1502 |
'class': 'test', |
| 1503 |
'format': custom_exploder, |
| 1504 |
} |
| 1505 |
] |
| 1506 |
} |
| 1507 |
} |
| 1508 |
|
| 1509 |
def test_broken(self): |
| 1510 |
"""Test broken fence.""" |
| 1511 |
|
| 1512 |
self.check_markdown( |
| 1513 |
''' |
| 1514 |
```test |
| 1515 |
doesn't matter |
| 1516 |
``` |
| 1517 |
''', |
| 1518 |
''' |
| 1519 |
<p><code>test |
| 1520 |
doesn't matter</code></p> |
| 1521 |
''', |
| 1522 |
True |
| 1523 |
) |
| 1524 |
|
| 1525 |
def test_broken_blockquote(self): |
| 1526 |
"""Test broken fence in a blockquote.""" |
| 1527 |
|
| 1528 |
self.check_markdown( |
| 1529 |
''' |
| 1530 |
> ```test |
| 1531 |
> doesn't matter |
| 1532 |
> ``` |
| 1533 |
''', |
| 1534 |
''' |
| 1535 |
<blockquote> |
| 1536 |
<p><code>test |
| 1537 |
doesn't matter</code></p> |
| 1538 |
</blockquote> |
| 1539 |
''', |
| 1540 |
True |
| 1541 |
) |
| 1542 |
|
| 1543 |
|
| 1544 |
class TestSuperFencesCustomBrokenFail(util.MdCase): |
| 1545 |
"""Test custom formatter that is broken and causes a failure.""" |
| 1546 |
|
| 1547 |
extension = ['pymdownx.superfences'] |
| 1548 |
extension_configs = { |
| 1549 |
'pymdownx.superfences': { |
| 1550 |
'custom_fences': [ |
| 1551 |
{ |
| 1552 |
'name': 'test', |
| 1553 |
'class': 'test', |
| 1554 |
'format': custom_exploder_fail, |
| 1555 |
} |
| 1556 |
] |
| 1557 |
} |
| 1558 |
} |
| 1559 |
|
| 1560 |
def test_custom_fail_exception(self): |
| 1561 |
"""Test custom fences forced exception.""" |
| 1562 |
|
| 1563 |
with self.assertRaises(SuperFencesException): |
| 1564 |
self.check_markdown( |
| 1565 |
r''' |
| 1566 |
```test |
| 1567 |
test |
| 1568 |
``` |
| 1569 |
''', |
| 1570 |
'', |
| 1571 |
True |
| 1572 |
) |
| 1573 |
|
| 1574 |
def test_custom_fail_exception_blockquote(self): |
| 1575 |
"""Test custom fences forced exception in a block quote.""" |
| 1576 |
|
| 1577 |
with self.assertRaises(SuperFencesException): |
| 1578 |
self.check_markdown( |
| 1579 |
r''' |
| 1580 |
> ```test |
| 1581 |
> test |
| 1582 |
> ``` |
| 1583 |
''', |
| 1584 |
'', |
| 1585 |
True |
| 1586 |
) |
| 1587 |
|
| 1588 |
|
| 1589 |
class TestSuperFencesCustomValidatorBroken(util.MdCase): |
| 1590 |
"""Test custom legacy validator that is broken.""" |
| 1591 |
|
| 1592 |
extension = ['pymdownx.superfences'] |
| 1593 |
extension_configs = { |
| 1594 |
'pymdownx.superfences': { |
| 1595 |
'custom_fences': [ |
| 1596 |
{ |
| 1597 |
'name': 'test', |
| 1598 |
'class': 'test', |
| 1599 |
'format': custom_format, |
| 1600 |
'validator': custom_validator_exploder |
| 1601 |
} |
| 1602 |
] |
| 1603 |
} |
| 1604 |
} |
| 1605 |
|
| 1606 |
def test_broken(self): |
| 1607 |
"""Test broken fence.""" |
| 1608 |
|
| 1609 |
self.check_markdown( |
| 1610 |
''' |
| 1611 |
```test |
| 1612 |
doesn't matter |
| 1613 |
``` |
| 1614 |
''', |
| 1615 |
''' |
| 1616 |
<div class="highlight"><pre><span></span><code>doesn't matter |
| 1617 |
</code></pre></div> |
| 1618 |
''', |
| 1619 |
True |
| 1620 |
) |
| 1621 |
|
| 1622 |
def test_broken_brace(self): |
| 1623 |
"""Test broken fence.""" |
| 1624 |
|
| 1625 |
self.check_markdown( |
| 1626 |
''' |
| 1627 |
```{.test} |
| 1628 |
doesn't matter |
| 1629 |
``` |
| 1630 |
''', |
| 1631 |
''' |
| 1632 |
<div class="highlight"><pre><span></span><code>doesn't matter |
| 1633 |
</code></pre></div> |
| 1634 |
''', |
| 1635 |
True |
| 1636 |
) |
| 1637 |
|
| 1638 |
|
| 1639 |
class TestHighlightRelaxedHeaders(util.MdCase): |
| 1640 |
"""Test relaxed header cases.""" |
| 1641 |
|
| 1642 |
extension = ['pymdownx.highlight', 'pymdownx.superfences', 'attr_list'] |
| 1643 |
extension_configs = { |
| 1644 |
'pymdownx.superfences': { |
| 1645 |
'relaxed_headers': True, |
| 1646 |
'custom_fences': [ |
| 1647 |
{ |
| 1648 |
'name': 'test', |
| 1649 |
'class': 'test', |
| 1650 |
'format': custom_format, |
| 1651 |
'validator': custom_validator_except |
| 1652 |
}, |
| 1653 |
{ |
| 1654 |
'name': 'test2', |
| 1655 |
'class': 'test', |
| 1656 |
'format': custom_format, |
| 1657 |
'validator': custom_validator_exploder |
| 1658 |
} |
| 1659 |
] |
| 1660 |
} |
| 1661 |
} |
| 1662 |
|
| 1663 |
def test_custom_fail_exception(self): |
| 1664 |
"""Test custom fences forced exception.""" |
| 1665 |
|
| 1666 |
with self.assertRaises(SuperFencesException): |
| 1667 |
self.check_markdown( |
| 1668 |
r''' |
| 1669 |
```test [1] |
| 1670 |
test |
| 1671 |
``` |
| 1672 |
''', |
| 1673 |
'', |
| 1674 |
True |
| 1675 |
) |
| 1676 |
|
| 1677 |
def test_custom_fail_exception_relaxed(self): |
| 1678 |
"""Test custom fences relaxed forced exception.""" |
| 1679 |
|
| 1680 |
self.check_markdown( |
| 1681 |
r''' |
| 1682 |
```test2 [1] |
| 1683 |
test |
| 1684 |
``` |
| 1685 |
''', |
| 1686 |
''' |
| 1687 |
<div class="highlight"><pre><span></span><code>test |
| 1688 |
</code></pre></div> |
| 1689 |
''', |
| 1690 |
True |
| 1691 |
) |
| 1692 |
|
| 1693 |
def test_bad_lang(self): |
| 1694 |
"""Test bad language.""" |
| 1695 |
|
| 1696 |
self.check_markdown( |
| 1697 |
r''' |
| 1698 |
```bad |
| 1699 |
test |
| 1700 |
``` |
| 1701 |
''', |
| 1702 |
''' |
| 1703 |
<div class="highlight"><pre><span></span><code>test |
| 1704 |
</code></pre></div> |
| 1705 |
''', |
| 1706 |
True |
| 1707 |
) |
| 1708 |
|
| 1709 |
def test_bad_option(self): |
| 1710 |
"""Test bad options.""" |
| 1711 |
|
| 1712 |
self.check_markdown( |
| 1713 |
r''' |
| 1714 |
```pycon bad="My title" |
| 1715 |
>>> import test |
| 1716 |
``` |
| 1717 |
''', |
| 1718 |
r''' |
| 1719 |
<div class="highlight"><pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 1720 |
</code></pre></div> |
| 1721 |
''', # noqa: E501 |
| 1722 |
True |
| 1723 |
) |
| 1724 |
|
| 1725 |
def test_bad_attribute(self): |
| 1726 |
"""Test bad attribute.""" |
| 1727 |
|
| 1728 |
self.check_markdown( |
| 1729 |
r''' |
| 1730 |
```pycon {.class <nonsense>!!!} |
| 1731 |
>>> import test |
| 1732 |
``` |
| 1733 |
''', |
| 1734 |
r''' |
| 1735 |
<div class="class highlight"><pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 1736 |
</code></pre></div> |
| 1737 |
''', # noqa: E501 |
| 1738 |
True |
| 1739 |
) |
| 1740 |
|
| 1741 |
def test_bad_attribute_full(self): |
| 1742 |
"""Test bad attribute full.""" |
| 1743 |
|
| 1744 |
self.check_markdown( |
| 1745 |
r''' |
| 1746 |
```{.pycon .class <nonsense>!!!} |
| 1747 |
>>> import test |
| 1748 |
``` |
| 1749 |
''', |
| 1750 |
r''' |
| 1751 |
<div class="class highlight"><pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 1752 |
</code></pre></div> |
| 1753 |
''', # noqa: E501 |
| 1754 |
True |
| 1755 |
) |
| 1756 |
|
| 1757 |
def test_bad_header(self): |
| 1758 |
"""Test bad header.""" |
| 1759 |
|
| 1760 |
self.check_markdown( |
| 1761 |
r''' |
| 1762 |
```pycon [nonsense] |
| 1763 |
>>> import test |
| 1764 |
``` |
| 1765 |
''', |
| 1766 |
r''' |
| 1767 |
<div class="highlight"><pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span> |
| 1768 |
</code></pre></div> |
| 1769 |
''', # noqa: E501 |
| 1770 |
True |
| 1771 |
) |
| 1772 |
|
| 1773 |
def test_nonsense(self): |
| 1774 |
"""Test only nonsense.""" |
| 1775 |
|
| 1776 |
self.check_markdown( |
| 1777 |
r''' |
| 1778 |
```[nonsense] |
| 1779 |
>>> import test |
| 1780 |
``` |
| 1781 |
''', |
| 1782 |
r''' |
| 1783 |
<div class="highlight"><pre><span></span><code>>>> import test |
| 1784 |
</code></pre></div> |
| 1785 |
''', |
| 1786 |
True |
| 1787 |
) |