| 1 |
"""Test cases for Details.""" |
| 2 |
from .. import util |
| 3 |
|
| 4 |
|
| 5 |
class TestFancyLists(util.MdCase): |
| 6 |
"""Test fancy lists.""" |
| 7 |
|
| 8 |
extension = ['pymdownx.fancylists', 'pymdownx.saneheaders'] |
| 9 |
extension_configs = {} |
| 10 |
|
| 11 |
def test_fail_case(self): |
| 12 |
"""Test failed case.""" |
| 13 |
|
| 14 |
self.check_markdown( |
| 15 |
""" |
| 16 |
1. foo |
| 17 |
. bar |
| 18 |
|
| 19 |
1) foo |
| 20 |
) bar |
| 21 |
""", |
| 22 |
""" |
| 23 |
<ol type="1"> |
| 24 |
<li>foo |
| 25 |
. bar</li> |
| 26 |
</ol> |
| 27 |
<ol type="1"> |
| 28 |
<li>foo |
| 29 |
) bar</li> |
| 30 |
</ol> |
| 31 |
""", |
| 32 |
True |
| 33 |
) |
| 34 |
|
| 35 |
def test_unordered(self): |
| 36 |
"""Test unordered lists.""" |
| 37 |
|
| 38 |
self.check_markdown( |
| 39 |
R''' |
| 40 |
- item 1 |
| 41 |
* item 2 |
| 42 |
+ item 3 |
| 43 |
''', |
| 44 |
r''' |
| 45 |
<ul> |
| 46 |
<li>item 1</li> |
| 47 |
<li>item 2</li> |
| 48 |
<li>item 3</li> |
| 49 |
</ul> |
| 50 |
''', |
| 51 |
True |
| 52 |
) |
| 53 |
|
| 54 |
def test_ordered(self): |
| 55 |
"""Test ordered lists.""" |
| 56 |
|
| 57 |
self.check_markdown( |
| 58 |
R''' |
| 59 |
1. item 1 |
| 60 |
2. item 2 |
| 61 |
3. item 3 |
| 62 |
''', |
| 63 |
r''' |
| 64 |
<ol type="1"> |
| 65 |
<li>item 1</li> |
| 66 |
<li>item 2</li> |
| 67 |
<li>item 3</li> |
| 68 |
</ol> |
| 69 |
''', |
| 70 |
True |
| 71 |
) |
| 72 |
|
| 73 |
def test_ordered_paren(self): |
| 74 |
"""Test ordered lists with parenthesis.""" |
| 75 |
|
| 76 |
self.check_markdown( |
| 77 |
R''' |
| 78 |
1) item 1 |
| 79 |
2) item 2 |
| 80 |
3) item 3 |
| 81 |
''', |
| 82 |
r''' |
| 83 |
<ol type="1"> |
| 84 |
<li>item 1</li> |
| 85 |
<li>item 2</li> |
| 86 |
<li>item 3</li> |
| 87 |
</ol> |
| 88 |
''', |
| 89 |
True |
| 90 |
) |
| 91 |
|
| 92 |
def test_ordered_generic(self): |
| 93 |
"""Test generic ordered list.""" |
| 94 |
|
| 95 |
self.check_markdown( |
| 96 |
R''' |
| 97 |
#. item 1 |
| 98 |
#. item 2 |
| 99 |
#. item 3 |
| 100 |
''', |
| 101 |
r''' |
| 102 |
<ol type="1"> |
| 103 |
<li>item 1</li> |
| 104 |
<li>item 2</li> |
| 105 |
<li>item 3</li> |
| 106 |
</ol> |
| 107 |
''', |
| 108 |
True |
| 109 |
) |
| 110 |
|
| 111 |
def test_ordered_generic_paren(self): |
| 112 |
"""Test generic ordered list with parenthesis.""" |
| 113 |
|
| 114 |
self.check_markdown( |
| 115 |
R''' |
| 116 |
#) item 1 |
| 117 |
#) item 2 |
| 118 |
#) item 3 |
| 119 |
''', |
| 120 |
r''' |
| 121 |
<ol type="1"> |
| 122 |
<li>item 1</li> |
| 123 |
<li>item 2</li> |
| 124 |
<li>item 3</li> |
| 125 |
</ol> |
| 126 |
''', |
| 127 |
True |
| 128 |
) |
| 129 |
|
| 130 |
def test_ordered_generic_switch(self): |
| 131 |
"""Test generic ordered list switching over to other style.""" |
| 132 |
|
| 133 |
self.check_markdown( |
| 134 |
R''' |
| 135 |
#. item 1 |
| 136 |
#. item 2 |
| 137 |
#) item 1 |
| 138 |
#) item 2 |
| 139 |
''', |
| 140 |
r''' |
| 141 |
<ol type="1"> |
| 142 |
<li>item 1</li> |
| 143 |
<li>item 2</li> |
| 144 |
</ol> |
| 145 |
<ol type="1"> |
| 146 |
<li>item 1</li> |
| 147 |
<li>item 2</li> |
| 148 |
</ol> |
| 149 |
''', |
| 150 |
True |
| 151 |
) |
| 152 |
|
| 153 |
def test_ordered_generic_inherit(self): |
| 154 |
"""Test generic ordered list inheritance.""" |
| 155 |
|
| 156 |
self.check_markdown( |
| 157 |
R''' |
| 158 |
i. item i |
| 159 |
#. item ii |
| 160 |
#. item iii |
| 161 |
I. New list |
| 162 |
''', |
| 163 |
r''' |
| 164 |
<ol type="i"> |
| 165 |
<li>item i</li> |
| 166 |
<li>item ii</li> |
| 167 |
<li>item iii</li> |
| 168 |
</ol> |
| 169 |
<ol type="I"> |
| 170 |
<li>New list</li> |
| 171 |
</ol> |
| 172 |
''', |
| 173 |
True |
| 174 |
) |
| 175 |
|
| 176 |
def test_ordered_generic_inherit_no_change(self): |
| 177 |
"""Test generic ordered list inheritance no new list if same type.""" |
| 178 |
|
| 179 |
self.check_markdown( |
| 180 |
R''' |
| 181 |
i. item i |
| 182 |
#. item ii |
| 183 |
#. item iii |
| 184 |
iv. item iv |
| 185 |
''', |
| 186 |
r''' |
| 187 |
<ol type="i"> |
| 188 |
<li>item i</li> |
| 189 |
<li>item ii</li> |
| 190 |
<li>item iii</li> |
| 191 |
<li>item iv</li> |
| 192 |
</ol> |
| 193 |
''', |
| 194 |
True |
| 195 |
) |
| 196 |
|
| 197 |
def test_roman(self): |
| 198 |
"""Test Roman numeral lists.""" |
| 199 |
|
| 200 |
self.check_markdown( |
| 201 |
R''' |
| 202 |
i. item 1 |
| 203 |
ii. item 2 |
| 204 |
iii. item 3 |
| 205 |
iv. item 4 |
| 206 |
v. item 5 |
| 207 |
vi. item 6 |
| 208 |
''', |
| 209 |
r''' |
| 210 |
<ol type="i"> |
| 211 |
<li>item 1</li> |
| 212 |
<li>item 2</li> |
| 213 |
<li>item 3</li> |
| 214 |
<li>item 4</li> |
| 215 |
<li>item 5</li> |
| 216 |
<li>item 6</li> |
| 217 |
</ol> |
| 218 |
''', |
| 219 |
True |
| 220 |
) |
| 221 |
|
| 222 |
def test_roman_paren(self): |
| 223 |
"""Test Roman numeral lists with parenthesis.""" |
| 224 |
|
| 225 |
self.check_markdown( |
| 226 |
R''' |
| 227 |
i) item 1 |
| 228 |
ii) item 2 |
| 229 |
iii) item 3 |
| 230 |
''', |
| 231 |
r''' |
| 232 |
<ol type="i"> |
| 233 |
<li>item 1</li> |
| 234 |
<li>item 2</li> |
| 235 |
<li>item 3</li> |
| 236 |
</ol> |
| 237 |
''', |
| 238 |
True |
| 239 |
) |
| 240 |
|
| 241 |
def test_roman_upper(self): |
| 242 |
"""Test Roman numeral uppercase lists.""" |
| 243 |
|
| 244 |
self.check_markdown( |
| 245 |
R''' |
| 246 |
I. item 1 |
| 247 |
II. item 2 |
| 248 |
III. item 3 |
| 249 |
''', |
| 250 |
r''' |
| 251 |
<ol type="I"> |
| 252 |
<li>item 1</li> |
| 253 |
<li>item 2</li> |
| 254 |
<li>item 3</li> |
| 255 |
</ol> |
| 256 |
''', |
| 257 |
True |
| 258 |
) |
| 259 |
|
| 260 |
def test_roman_upper_paren(self): |
| 261 |
"""Test Roman numeral uppercase lists with parenthesis.""" |
| 262 |
|
| 263 |
self.check_markdown( |
| 264 |
R''' |
| 265 |
I) item 1 |
| 266 |
II) item 2 |
| 267 |
III) item 3 |
| 268 |
''', |
| 269 |
r''' |
| 270 |
<ol type="I"> |
| 271 |
<li>item 1</li> |
| 272 |
<li>item 2</li> |
| 273 |
<li>item 3</li> |
| 274 |
</ol> |
| 275 |
''', |
| 276 |
True |
| 277 |
) |
| 278 |
|
| 279 |
def test_alpha(self): |
| 280 |
"""Test alphabetical lists.""" |
| 281 |
|
| 282 |
self.check_markdown( |
| 283 |
R''' |
| 284 |
a. item 1 |
| 285 |
b. item 2 |
| 286 |
c. item 3 |
| 287 |
''', |
| 288 |
r''' |
| 289 |
<ol type="a"> |
| 290 |
<li>item 1</li> |
| 291 |
<li>item 2</li> |
| 292 |
<li>item 3</li> |
| 293 |
</ol> |
| 294 |
''', |
| 295 |
True |
| 296 |
) |
| 297 |
|
| 298 |
def test_alpha_paren(self): |
| 299 |
"""Test alphabetical lists with parenthesis.""" |
| 300 |
|
| 301 |
self.check_markdown( |
| 302 |
R''' |
| 303 |
a) item 1 |
| 304 |
b) item 2 |
| 305 |
c) item 3 |
| 306 |
''', |
| 307 |
r''' |
| 308 |
<ol type="a"> |
| 309 |
<li>item 1</li> |
| 310 |
<li>item 2</li> |
| 311 |
<li>item 3</li> |
| 312 |
</ol> |
| 313 |
''', |
| 314 |
True |
| 315 |
) |
| 316 |
|
| 317 |
def test_alpha_upper(self): |
| 318 |
"""Test alphabetical uppercase lists.""" |
| 319 |
|
| 320 |
self.check_markdown( |
| 321 |
R''' |
| 322 |
A. item 1 |
| 323 |
B. item 2 |
| 324 |
C. item 3 |
| 325 |
''', |
| 326 |
r''' |
| 327 |
<ol type="A"> |
| 328 |
<li>item 1</li> |
| 329 |
<li>item 2</li> |
| 330 |
<li>item 3</li> |
| 331 |
</ol> |
| 332 |
''', |
| 333 |
True |
| 334 |
) |
| 335 |
|
| 336 |
def test_alpha_upper_paren(self): |
| 337 |
"""Test alphabetical uppercase lists with parenthesis.""" |
| 338 |
|
| 339 |
self.check_markdown( |
| 340 |
R''' |
| 341 |
A) item 1 |
| 342 |
B) item 2 |
| 343 |
C) item 3 |
| 344 |
''', |
| 345 |
r''' |
| 346 |
<ol type="A"> |
| 347 |
<li>item 1</li> |
| 348 |
<li>item 2</li> |
| 349 |
<li>item 3</li> |
| 350 |
</ol> |
| 351 |
''', |
| 352 |
True |
| 353 |
) |
| 354 |
|
| 355 |
def test_alpha_two_spaces(self): |
| 356 |
"""Test alphabetical two space uppercase requirement.""" |
| 357 |
|
| 358 |
self.check_markdown( |
| 359 |
R''' |
| 360 |
A. item 1 |
| 361 |
A. item 2 |
| 362 |
''', |
| 363 |
R''' |
| 364 |
<ol type="A"> |
| 365 |
<li>item 1 |
| 366 |
A. item 2</li> |
| 367 |
</ol> |
| 368 |
''', |
| 369 |
True |
| 370 |
) |
| 371 |
|
| 372 |
def test_roman_alpha(self): |
| 373 |
"""Test behavior of alphabetical and Roman numeral.""" |
| 374 |
|
| 375 |
self.check_markdown( |
| 376 |
R''' |
| 377 |
v) item 1 |
| 378 |
a) item 2 |
| 379 |
|
| 380 |
i. item 1 |
| 381 |
a. item 1 |
| 382 |
b. item 2 |
| 383 |
|
| 384 |
''', |
| 385 |
r''' |
| 386 |
<ol start="22" type="a"> |
| 387 |
<li>item 1</li> |
| 388 |
<li>item 2</li> |
| 389 |
</ol> |
| 390 |
<ol type="i"> |
| 391 |
<li>item 1</li> |
| 392 |
</ol> |
| 393 |
<ol type="a"> |
| 394 |
<li>item 1</li> |
| 395 |
<li>item 2</li> |
| 396 |
</ol> |
| 397 |
''', |
| 398 |
True |
| 399 |
) |
| 400 |
|
| 401 |
def test_bad_roman(self): |
| 402 |
"""Test bad Roman numeral.""" |
| 403 |
|
| 404 |
self.check_markdown( |
| 405 |
R''' |
| 406 |
iviv. item 1 |
| 407 |
''', |
| 408 |
R''' |
| 409 |
<p>iviv. item 1</p> |
| 410 |
''', |
| 411 |
True |
| 412 |
) |
| 413 |
|
| 414 |
|
| 415 |
def test_roman_start(self): |
| 416 |
"""Test bad Roman numeral.""" |
| 417 |
|
| 418 |
self.check_markdown( |
| 419 |
R''' |
| 420 |
iv. item 1 |
| 421 |
v. item 2 |
| 422 |
''', |
| 423 |
R''' |
| 424 |
<ol start="4" type="i"> |
| 425 |
<li>item 1</li> |
| 426 |
<li>item 2</li> |
| 427 |
</ol> |
| 428 |
''', |
| 429 |
True |
| 430 |
) |
| 431 |
|
| 432 |
def test_roman_two_spaces(self): |
| 433 |
"""Test Roman numeral two space uppercase requirement.""" |
| 434 |
|
| 435 |
self.check_markdown( |
| 436 |
R''' |
| 437 |
I. item 1 |
| 438 |
I. item 2 |
| 439 |
''', |
| 440 |
R''' |
| 441 |
<ol type="I"> |
| 442 |
<li>item 1 |
| 443 |
I. item 2</li> |
| 444 |
</ol> |
| 445 |
''', |
| 446 |
True |
| 447 |
) |
| 448 |
|
| 449 |
def test_roman_relaxed(self): |
| 450 |
"""Test cases related to our less strict approach.""" |
| 451 |
|
| 452 |
self.check_markdown( |
| 453 |
R''' |
| 454 |
iiii. item 1 |
| 455 |
|
| 456 |
MCCCCCCVI. item 1 |
| 457 |
''', |
| 458 |
R''' |
| 459 |
<ol start="4" type="i"> |
| 460 |
<li>item 1</li> |
| 461 |
</ol> |
| 462 |
<ol start="1606" type="I"> |
| 463 |
<li>item 1</li> |
| 464 |
</ol> |
| 465 |
''', |
| 466 |
True |
| 467 |
) |
| 468 |
|
| 469 |
def test_list_nested_same_line(self): |
| 470 |
"""Test list nested on same line.""" |
| 471 |
|
| 472 |
self.check_markdown( |
| 473 |
R''' |
| 474 |
a) a) subitem1 |
| 475 |
b) subitem2 |
| 476 |
''', |
| 477 |
R''' |
| 478 |
<ol type="a"> |
| 479 |
<li> |
| 480 |
<ol type="a"> |
| 481 |
<li>subitem1</li> |
| 482 |
<li>subitem2</li> |
| 483 |
</ol> |
| 484 |
</li> |
| 485 |
</ol> |
| 486 |
''', |
| 487 |
True |
| 488 |
) |
| 489 |
|
| 490 |
def test_indented_content(self): |
| 491 |
"""Test indented content.""" |
| 492 |
|
| 493 |
self.check_markdown( |
| 494 |
R''' |
| 495 |
#. A paragraph |
| 496 |
that is short. |
| 497 |
|
| 498 |
Another paragraph. |
| 499 |
|
| 500 |
#. A sublist |
| 501 |
|
| 502 |
Another paragraph. |
| 503 |
|
| 504 |
#. A new list item. |
| 505 |
''', |
| 506 |
R''' |
| 507 |
<ol type="1"> |
| 508 |
<li> |
| 509 |
<p>A paragraph |
| 510 |
that is short.</p> |
| 511 |
<p>Another paragraph.</p> |
| 512 |
<ol type="1"> |
| 513 |
<li>A sublist</li> |
| 514 |
</ol> |
| 515 |
<p>Another paragraph.</p> |
| 516 |
</li> |
| 517 |
<li> |
| 518 |
<p>A new list item.</p> |
| 519 |
</li> |
| 520 |
</ol> |
| 521 |
''', |
| 522 |
True |
| 523 |
) |
| 524 |
|
| 525 |
def test_unindented_content(self): |
| 526 |
"""Test indented content with unindented lines.""" |
| 527 |
|
| 528 |
self.check_markdown( |
| 529 |
R''' |
| 530 |
#. A paragraph |
| 531 |
that is short. |
| 532 |
|
| 533 |
Another paragraph |
| 534 |
with unindented lines. |
| 535 |
|
| 536 |
#. A sublist |
| 537 |
with unindented lines. |
| 538 |
|
| 539 |
#. A new list item. |
| 540 |
''', |
| 541 |
R''' |
| 542 |
<ol type="1"> |
| 543 |
<li> |
| 544 |
<p>A paragraph |
| 545 |
that is short.</p> |
| 546 |
<p>Another paragraph |
| 547 |
with unindented lines.</p> |
| 548 |
<ol type="1"> |
| 549 |
<li>A sublist |
| 550 |
with unindented lines.</li> |
| 551 |
</ol> |
| 552 |
</li> |
| 553 |
<li> |
| 554 |
<p>A new list item.</p> |
| 555 |
</li> |
| 556 |
</ol> |
| 557 |
''', |
| 558 |
True |
| 559 |
) |
| 560 |
|
| 561 |
def test_header_case(self): |
| 562 |
"""Test case where list follows header.""" |
| 563 |
|
| 564 |
self.check_markdown( |
| 565 |
R''' |
| 566 |
Tight List: |
| 567 |
|
| 568 |
* # Header1 |
| 569 |
Line 1-2 - **not** a header *or* paragraph! |
| 570 |
* # Header2 |
| 571 |
Line 2-2 - not a header or paragraph! |
| 572 |
|
| 573 |
Loose List: |
| 574 |
|
| 575 |
* # Header1 |
| 576 |
Line 1-2 - *a* paragraph |
| 577 |
|
| 578 |
* # Header2 |
| 579 |
Line 2-2 - a paragraph |
| 580 |
''', |
| 581 |
R''' |
| 582 |
<p>Tight List:</p> |
| 583 |
<ul> |
| 584 |
<li> |
| 585 |
<h1>Header1</h1> |
| 586 |
Line 1-2 - <strong>not</strong> a header <em>or</em> paragraph!</li> |
| 587 |
<li> |
| 588 |
<h1>Header2</h1> |
| 589 |
Line 2-2 - not a header or paragraph!</li> |
| 590 |
</ul> |
| 591 |
<p>Loose List:</p> |
| 592 |
<ul> |
| 593 |
<li> |
| 594 |
<h1>Header1</h1> |
| 595 |
<p>Line 1-2 - <em>a</em> paragraph</p> |
| 596 |
</li> |
| 597 |
<li> |
| 598 |
<h1>Header2</h1> |
| 599 |
<p>Line 2-2 - a paragraph</p> |
| 600 |
</li> |
| 601 |
</ul> |
| 602 |
''', |
| 603 |
True |
| 604 |
) |
| 605 |
|
| 606 |
def test_mixed_nesting_case(self): |
| 607 |
"""Test mixed nesting case.""" |
| 608 |
|
| 609 |
self.check_markdown( |
| 610 |
R''' |
| 611 |
* item 1 |
| 612 |
* item 1-1 |
| 613 |
* item 1-2 |
| 614 |
* item 1-2-1 |
| 615 |
* item 2 |
| 616 |
* item 3 |
| 617 |
* item 4 |
| 618 |
* item 4-1 |
| 619 |
* item 4-2 |
| 620 |
* item 4-3 |
| 621 |
|
| 622 |
Paragraph under item 4-3 |
| 623 |
|
| 624 |
Paragraph under item 4 |
| 625 |
''', |
| 626 |
R''' |
| 627 |
<ul> |
| 628 |
<li>item 1<ul> |
| 629 |
<li>item 1-1</li> |
| 630 |
<li>item 1-2<ul> |
| 631 |
<li>item 1-2-1</li> |
| 632 |
</ul> |
| 633 |
</li> |
| 634 |
</ul> |
| 635 |
</li> |
| 636 |
<li>item 2</li> |
| 637 |
<li>item 3</li> |
| 638 |
<li> |
| 639 |
<p>item 4</p> |
| 640 |
<ul> |
| 641 |
<li>item 4-1</li> |
| 642 |
<li>item 4-2</li> |
| 643 |
<li> |
| 644 |
<p>item 4-3</p> |
| 645 |
<p>Paragraph under item 4-3</p> |
| 646 |
</li> |
| 647 |
</ul> |
| 648 |
<p>Paragraph under item 4</p> |
| 649 |
</li> |
| 650 |
</ul> |
| 651 |
''', |
| 652 |
True |
| 653 |
) |
| 654 |
|
| 655 |
def test_tight_loose_mix(self): |
| 656 |
"""Test inconsistent loose and tight list item spacing.""" |
| 657 |
|
| 658 |
self.check_markdown( |
| 659 |
R''' |
| 660 |
* item 1 |
| 661 |
* item 2 |
| 662 |
|
| 663 |
* item 3 |
| 664 |
* item 4 |
| 665 |
''', |
| 666 |
R''' |
| 667 |
<ul> |
| 668 |
<li>item 1</li> |
| 669 |
<li> |
| 670 |
<p>item 2</p> |
| 671 |
</li> |
| 672 |
<li> |
| 673 |
<p>item 3</p> |
| 674 |
</li> |
| 675 |
<li>item 4</li> |
| 676 |
</ul> |
| 677 |
''', |
| 678 |
True |
| 679 |
) |
| 680 |
|
| 681 |
def test_roman_mitigation(self): |
| 682 |
"""Test mitigation for conflict case with alphabetical lists.""" |
| 683 |
|
| 684 |
self.check_markdown( |
| 685 |
R''' |
| 686 |
IIIII. Roman numeral V |
| 687 |
|
| 688 |
--- |
| 689 |
|
| 690 |
VIIIII. Roman numeral X |
| 691 |
|
| 692 |
--- |
| 693 |
|
| 694 |
XXXXX. Roman numeral L |
| 695 |
|
| 696 |
--- |
| 697 |
|
| 698 |
LXXXXX. Roman numeral C |
| 699 |
|
| 700 |
--- |
| 701 |
|
| 702 |
CCCCC. Roman numeral D |
| 703 |
|
| 704 |
--- |
| 705 |
|
| 706 |
DCCCCC. Roman numeral M |
| 707 |
|
| 708 |
/// fancylists | start=5 type=I |
| 709 |
V. Alternate work around |
| 710 |
/// |
| 711 |
''', |
| 712 |
R''' |
| 713 |
<ol start="5" type="I"> |
| 714 |
<li>Roman numeral V</li> |
| 715 |
</ol> |
| 716 |
<hr /> |
| 717 |
<ol start="10" type="I"> |
| 718 |
<li>Roman numeral X</li> |
| 719 |
</ol> |
| 720 |
<hr /> |
| 721 |
<ol start="50" type="I"> |
| 722 |
<li>Roman numeral L</li> |
| 723 |
</ol> |
| 724 |
<hr /> |
| 725 |
<ol start="100" type="I"> |
| 726 |
<li>Roman numeral C</li> |
| 727 |
</ol> |
| 728 |
<hr /> |
| 729 |
<ol start="500" type="I"> |
| 730 |
<li>Roman numeral D</li> |
| 731 |
</ol> |
| 732 |
<hr /> |
| 733 |
<ol start="1000" type="I"> |
| 734 |
<li>Roman numeral M</li> |
| 735 |
</ol> |
| 736 |
<ol start="5" type="I"> |
| 737 |
<li>Alternate work around</li> |
| 738 |
</ol> |
| 739 |
''', |
| 740 |
True |
| 741 |
) |
| 742 |
|
| 743 |
def test_alpha_mitigation_start(self): |
| 744 |
"""Test mitigation for conflict case with Roman numeral lists with explicit start.""" |
| 745 |
|
| 746 |
self.check_markdown( |
| 747 |
R''' |
| 748 |
/// fancylists | start=3 type=a |
| 749 |
i. Workaround |
| 750 |
j. Workaround |
| 751 |
/// |
| 752 |
''', |
| 753 |
R''' |
| 754 |
<ol start="3" type="a"> |
| 755 |
<li>Workaround</li> |
| 756 |
<li>Workaround</li> |
| 757 |
</ol> |
| 758 |
''', |
| 759 |
True |
| 760 |
) |
| 761 |
|
| 762 |
|
| 763 |
def test_alpha_mitigation(self): |
| 764 |
"""Test mitigation for conflict case with Roman numeral lists with explicit start.""" |
| 765 |
|
| 766 |
self.check_markdown( |
| 767 |
R''' |
| 768 |
/// fancylists | type=a |
| 769 |
i. Workaround |
| 770 |
j. Workaround |
| 771 |
/// |
| 772 |
|
| 773 |
/// fancylists | type=a |
| 774 |
i) Workaround |
| 775 |
j) Workaround |
| 776 |
/// |
| 777 |
''', |
| 778 |
R''' |
| 779 |
<ol start="9" type="a"> |
| 780 |
<li>Workaround</li> |
| 781 |
<li>Workaround</li> |
| 782 |
</ol> |
| 783 |
<ol start="9" type="a"> |
| 784 |
<li>Workaround</li> |
| 785 |
<li>Workaround</li> |
| 786 |
</ol> |
| 787 |
''', |
| 788 |
True |
| 789 |
) |
| 790 |
|
| 791 |
def test_alpha_mitigation_switch(self): |
| 792 |
"""Test mitigation for conflict case with Roman numeral lists.""" |
| 793 |
|
| 794 |
self.check_markdown( |
| 795 |
R''' |
| 796 |
/// fancylists | type=a |
| 797 |
i. Workaround |
| 798 |
j) Workaround |
| 799 |
/// |
| 800 |
''', |
| 801 |
R''' |
| 802 |
<ol start="9" type="a"> |
| 803 |
<li>Workaround</li> |
| 804 |
</ol> |
| 805 |
<ol start="10" type="a"> |
| 806 |
<li>Workaround</li> |
| 807 |
</ol> |
| 808 |
''', |
| 809 |
True |
| 810 |
) |
| 811 |
|
| 812 |
def test_alpha_mitigation_complex(self): |
| 813 |
"""Test mitigation for complex conflict case with Roman numeral lists.""" |
| 814 |
|
| 815 |
self.check_markdown( |
| 816 |
R''' |
| 817 |
/// fancylists | type=a |
| 818 |
i. Workaround |
| 819 |
|
| 820 |
Workaround |
| 821 |
|
| 822 |
j. Workaround |
| 823 |
/// |
| 824 |
''', |
| 825 |
R''' |
| 826 |
<ol start="9" type="a"> |
| 827 |
<li> |
| 828 |
<p>Workaround</p> |
| 829 |
<p>Workaround</p> |
| 830 |
</li> |
| 831 |
<li> |
| 832 |
<p>Workaround</p> |
| 833 |
</li> |
| 834 |
</ol> |
| 835 |
''', |
| 836 |
True |
| 837 |
) |
| 838 |
|
| 839 |
def test_alpha_mitigation_ul_ignored(self): |
| 840 |
"""Test that mitigation won't target unordered lists.""" |
| 841 |
|
| 842 |
self.check_markdown( |
| 843 |
R''' |
| 844 |
/// fancylists | type=a |
| 845 |
- Workaround |
| 846 |
|
| 847 |
Workaround |
| 848 |
|
| 849 |
- Workaround |
| 850 |
/// |
| 851 |
''', |
| 852 |
R''' |
| 853 |
<ul> |
| 854 |
<li> |
| 855 |
<p>Workaround</p> |
| 856 |
<p>Workaround</p> |
| 857 |
</li> |
| 858 |
<li> |
| 859 |
<p>Workaround</p> |
| 860 |
</li> |
| 861 |
</ul> |
| 862 |
''', |
| 863 |
True |
| 864 |
) |
| 865 |
|
| 866 |
def test_alpha_mitigation_generic(self): |
| 867 |
"""Test that mitigation works on generic.""" |
| 868 |
|
| 869 |
self.check_markdown( |
| 870 |
R''' |
| 871 |
/// fancylists | start=9 type=a |
| 872 |
#. Workaround |
| 873 |
|
| 874 |
Workaround |
| 875 |
|
| 876 |
#. Workaround |
| 877 |
/// |
| 878 |
''', |
| 879 |
R''' |
| 880 |
<ol start="9" type="a"> |
| 881 |
<li> |
| 882 |
<p>Workaround</p> |
| 883 |
<p>Workaround</p> |
| 884 |
</li> |
| 885 |
<li> |
| 886 |
<p>Workaround</p> |
| 887 |
</li> |
| 888 |
</ol> |
| 889 |
''', |
| 890 |
True |
| 891 |
) |
| 892 |
|
| 893 |
def test_alpha_mitigation_generic_no_start(self): |
| 894 |
"""Test that mitigation works on generic with no start.""" |
| 895 |
|
| 896 |
self.check_markdown( |
| 897 |
R''' |
| 898 |
/// fancylists | type=a |
| 899 |
#. Workaround |
| 900 |
|
| 901 |
Workaround |
| 902 |
|
| 903 |
#. Workaround |
| 904 |
/// |
| 905 |
''', |
| 906 |
R''' |
| 907 |
<ol type="a"> |
| 908 |
<li> |
| 909 |
<p>Workaround</p> |
| 910 |
<p>Workaround</p> |
| 911 |
</li> |
| 912 |
<li> |
| 913 |
<p>Workaround</p> |
| 914 |
</li> |
| 915 |
</ol> |
| 916 |
''', |
| 917 |
True |
| 918 |
) |
| 919 |
|
| 920 |
def test_mitigation_no_force_alpha(self): |
| 921 |
"""Test case that can't be forced.""" |
| 922 |
|
| 923 |
self.check_markdown( |
| 924 |
R''' |
| 925 |
/// fancylists | type=a |
| 926 |
1. Can't force |
| 927 |
/// |
| 928 |
''', |
| 929 |
R''' |
| 930 |
<ol type="a"> |
| 931 |
<li>Can't force</li> |
| 932 |
</ol> |
| 933 |
''', |
| 934 |
True |
| 935 |
) |
| 936 |
|
| 937 |
def test_mitigation_bad_type(self): |
| 938 |
"""Test bad type in mitigation.""" |
| 939 |
|
| 940 |
self.check_markdown( |
| 941 |
R''' |
| 942 |
/// fancylists | type=j |
| 943 |
|
| 944 |
1. Can't force |
| 945 |
/// |
| 946 |
''', |
| 947 |
R''' |
| 948 |
<p>/// fancylists | type=j</p> |
| 949 |
<ol type="1"> |
| 950 |
<li>Can't force |
| 951 |
///</li> |
| 952 |
</ol> |
| 953 |
''', |
| 954 |
True |
| 955 |
) |
| 956 |
|
| 957 |
def test_mitigation_no_type(self): |
| 958 |
"""Test no type in mitigation.""" |
| 959 |
|
| 960 |
self.check_markdown( |
| 961 |
R''' |
| 962 |
/// fancylists | |
| 963 |
|
| 964 |
a. Can't force |
| 965 |
/// |
| 966 |
''', |
| 967 |
R''' |
| 968 |
<p>/// fancylists |</p> |
| 969 |
<ol type="a"> |
| 970 |
<li>Can't force |
| 971 |
///</li> |
| 972 |
</ol> |
| 973 |
''', |
| 974 |
True |
| 975 |
) |
| 976 |
|
| 977 |
def test_mitigation_only_start(self): |
| 978 |
"""Test no type in mitigation.""" |
| 979 |
|
| 980 |
self.check_markdown( |
| 981 |
R''' |
| 982 |
/// fancylists | start=5 |
| 983 |
|
| 984 |
a. item 5 |
| 985 |
/// |
| 986 |
''', |
| 987 |
R''' |
| 988 |
<ol start="5" type="1"> |
| 989 |
<li>item 5</li> |
| 990 |
</ol> |
| 991 |
''', |
| 992 |
True |
| 993 |
) |
| 994 |
|
| 995 |
|
| 996 |
class TestFancyListsStyle(util.MdCase): |
| 997 |
"""Test fancy lists.""" |
| 998 |
|
| 999 |
extension = ['pymdownx.fancylists', 'pymdownx.saneheaders'] |
| 1000 |
extension_configs = { |
| 1001 |
'pymdownx.fancylists': { |
| 1002 |
'inject_style': True |
| 1003 |
} |
| 1004 |
} |
| 1005 |
|
| 1006 |
def test_inject_style(self): |
| 1007 |
"""Test injecting styles.""" |
| 1008 |
|
| 1009 |
self.check_markdown( |
| 1010 |
R''' |
| 1011 |
i. Item i |
| 1012 |
''', |
| 1013 |
R''' |
| 1014 |
<ol style="list-style-type: lower-roman;" type="i"> |
| 1015 |
<li>Item i</li> |
| 1016 |
</ol> |
| 1017 |
''', |
| 1018 |
True |
| 1019 |
) |
| 1020 |
|
| 1021 |
def test_inject_style_force(self): |
| 1022 |
"""Test injecting styles in forced lists.""" |
| 1023 |
|
| 1024 |
self.check_markdown( |
| 1025 |
R''' |
| 1026 |
/// fancylists | type=i |
| 1027 |
v. Item v |
| 1028 |
/// |
| 1029 |
''', |
| 1030 |
R''' |
| 1031 |
<ol start="5" style="list-style-type: lower-roman;" type="i"> |
| 1032 |
<li>Item v</li> |
| 1033 |
</ol> |
| 1034 |
''', |
| 1035 |
True |
| 1036 |
) |
| 1037 |
|
| 1038 |
|
| 1039 |
class TestFancyListsClass(util.MdCase): |
| 1040 |
"""Test fancy lists.""" |
| 1041 |
|
| 1042 |
extension = ['pymdownx.fancylists', 'pymdownx.saneheaders'] |
| 1043 |
extension_configs = { |
| 1044 |
'pymdownx.fancylists': { |
| 1045 |
'inject_class': True |
| 1046 |
} |
| 1047 |
} |
| 1048 |
|
| 1049 |
def test_inject_class(self): |
| 1050 |
"""Test injecting class.""" |
| 1051 |
|
| 1052 |
self.check_markdown( |
| 1053 |
R''' |
| 1054 |
i. Item i |
| 1055 |
''', |
| 1056 |
R''' |
| 1057 |
<ol class="fancylists-lower-roman" type="i"> |
| 1058 |
<li>Item i</li> |
| 1059 |
</ol> |
| 1060 |
''', |
| 1061 |
True |
| 1062 |
) |
| 1063 |
|
| 1064 |
def test_inject_class_force(self): |
| 1065 |
"""Test injecting class in forced lists.""" |
| 1066 |
|
| 1067 |
self.check_markdown( |
| 1068 |
R''' |
| 1069 |
/// fancylists | type=i |
| 1070 |
v. Item v |
| 1071 |
/// |
| 1072 |
''', |
| 1073 |
R''' |
| 1074 |
<ol class="fancylists-lower-roman" start="5" type="i"> |
| 1075 |
<li>Item v</li> |
| 1076 |
</ol> |
| 1077 |
''', |
| 1078 |
True |
| 1079 |
) |
| 1080 |
|
| 1081 |
|
| 1082 |
class TestFancyListsDisableAlpha(util.MdCase): |
| 1083 |
"""Test fancy lists.""" |
| 1084 |
|
| 1085 |
extension = ['pymdownx.fancylists', 'pymdownx.saneheaders'] |
| 1086 |
extension_configs = { |
| 1087 |
'pymdownx.fancylists': { |
| 1088 |
'additional_ordered_styles': ['roman', 'generic'] |
| 1089 |
} |
| 1090 |
} |
| 1091 |
|
| 1092 |
def test_no_alpha(self): |
| 1093 |
"""Test lists when alphabetical lists is disabled.""" |
| 1094 |
|
| 1095 |
self.check_markdown( |
| 1096 |
R''' |
| 1097 |
i. item 1 |
| 1098 |
ii. item 2 |
| 1099 |
|
| 1100 |
a. item 1 |
| 1101 |
|
| 1102 |
V. item 1 |
| 1103 |
''', |
| 1104 |
R''' |
| 1105 |
<ol type="i"> |
| 1106 |
<li>item 1</li> |
| 1107 |
<li>item 2</li> |
| 1108 |
</ol> |
| 1109 |
<p>a. item 1</p> |
| 1110 |
<ol start="5" type="I"> |
| 1111 |
<li>item 1</li> |
| 1112 |
</ol> |
| 1113 |
''', |
| 1114 |
True |
| 1115 |
) |
| 1116 |
|
| 1117 |
def test_no_alpha_force(self): |
| 1118 |
"""Test attempting to force alphabetical when they are disabled.""" |
| 1119 |
|
| 1120 |
self.check_markdown( |
| 1121 |
R''' |
| 1122 |
/// fancylists | type=a |
| 1123 |
|
| 1124 |
i. item 1 |
| 1125 |
j. item 2 |
| 1126 |
/// |
| 1127 |
''', |
| 1128 |
R''' |
| 1129 |
<p>/// fancylists | type=a</p> |
| 1130 |
<ol type="i"> |
| 1131 |
<li>item 1 |
| 1132 |
j. item 2 |
| 1133 |
///</li> |
| 1134 |
</ol> |
| 1135 |
''', |
| 1136 |
True |
| 1137 |
) |
| 1138 |
|
| 1139 |
|
| 1140 |
class TestFancyListsDisableRoman(util.MdCase): |
| 1141 |
"""Test fancy lists.""" |
| 1142 |
|
| 1143 |
extension = ['pymdownx.fancylists', 'pymdownx.saneheaders'] |
| 1144 |
extension_configs = { |
| 1145 |
'pymdownx.fancylists': { |
| 1146 |
'additional_ordered_styles': ['alpha', 'generic'] |
| 1147 |
} |
| 1148 |
} |
| 1149 |
|
| 1150 |
def test_no_roman(self): |
| 1151 |
"""Test lists when Roman numerals lists is disabled.""" |
| 1152 |
|
| 1153 |
self.check_markdown( |
| 1154 |
R''' |
| 1155 |
i. item 1 |
| 1156 |
ii. item 2 |
| 1157 |
|
| 1158 |
a. item 2 |
| 1159 |
|
| 1160 |
V. item 1 |
| 1161 |
''', |
| 1162 |
R''' |
| 1163 |
<ol start="9" type="a"> |
| 1164 |
<li> |
| 1165 |
<p>item 1 |
| 1166 |
ii. item 2</p> |
| 1167 |
</li> |
| 1168 |
<li> |
| 1169 |
<p>item 2</p> |
| 1170 |
</li> |
| 1171 |
</ol> |
| 1172 |
<ol start="22" type="A"> |
| 1173 |
<li>item 1</li> |
| 1174 |
</ol> |
| 1175 |
''', |
| 1176 |
True |
| 1177 |
) |
| 1178 |
|
| 1179 |
def test_no_roman_force(self): |
| 1180 |
"""Test attempting to force Roman numerals when they are disabled.""" |
| 1181 |
|
| 1182 |
self.check_markdown( |
| 1183 |
R''' |
| 1184 |
/// fancylists | type=i |
| 1185 |
|
| 1186 |
v. item 1 |
| 1187 |
vi. item 2 |
| 1188 |
/// |
| 1189 |
''', |
| 1190 |
R''' |
| 1191 |
<p>/// fancylists | type=i</p> |
| 1192 |
<ol start="22" type="a"> |
| 1193 |
<li>item 1 |
| 1194 |
vi. item 2 |
| 1195 |
///</li> |
| 1196 |
</ol> |
| 1197 |
''', |
| 1198 |
True |
| 1199 |
) |