| 1 |
"""Test cases for Tabbed.""" |
| 2 |
from .. import util |
| 3 |
from pymdownx.slugs import slugify |
| 4 |
|
| 5 |
|
| 6 |
class TestLegacyTab(util.MdCase): |
| 7 |
"""Test legacy tab cases.""" |
| 8 |
|
| 9 |
extension = ['pymdownx.tabbed', 'pymdownx.superfences', 'markdown.extensions.def_list', 'pymdownx.details'] |
| 10 |
extension_configs = {} |
| 11 |
|
| 12 |
def test_with_preceding_text(self): |
| 13 |
"""Test content directly before tabs.""" |
| 14 |
|
| 15 |
expected = r''' |
| 16 |
<p>foo |
| 17 |
<strong>foo</strong></p> |
| 18 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab</label><div class="tabbed-content"></div> |
| 19 |
</div> |
| 20 |
''' # noqa: E501 |
| 21 |
|
| 22 |
self.check_markdown( |
| 23 |
r''' |
| 24 |
foo |
| 25 |
**foo** |
| 26 |
=== "Tab" |
| 27 |
''', |
| 28 |
expected, |
| 29 |
True |
| 30 |
) |
| 31 |
|
| 32 |
def test_tabbed(self): |
| 33 |
"""Test tabbed.""" |
| 34 |
|
| 35 |
self.check_markdown( |
| 36 |
r''' |
| 37 |
=== "Tab" |
| 38 |
Some *content* |
| 39 |
|
| 40 |
And more `content`. |
| 41 |
|
| 42 |
=== "Another Tab" |
| 43 |
Some more content. |
| 44 |
|
| 45 |
``` |
| 46 |
code |
| 47 |
``` |
| 48 |
''', |
| 49 |
r''' |
| 50 |
<div class="tabbed-set" data-tabs="1:2"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab</label><div class="tabbed-content"> |
| 51 |
<p>Some <em>content</em></p> |
| 52 |
<p>And more <code>content</code>.</p> |
| 53 |
</div> |
| 54 |
<input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><label for="__tabbed_1_2">Another Tab</label><div class="tabbed-content"> |
| 55 |
<p>Some more content.</p> |
| 56 |
<div class="highlight"><pre><span></span><code>code |
| 57 |
</code></pre></div> |
| 58 |
</div> |
| 59 |
</div> |
| 60 |
''', # noqa: E501 |
| 61 |
True |
| 62 |
) |
| 63 |
|
| 64 |
def test_tabbed_markdown_title(self): |
| 65 |
"""Test tabbed.""" |
| 66 |
|
| 67 |
self.check_markdown( |
| 68 |
R''' |
| 69 |
=== "**Tab**" |
| 70 |
Some *content* |
| 71 |
|
| 72 |
And more `content`. |
| 73 |
|
| 74 |
=== "_Another Tab_" |
| 75 |
Some more content. |
| 76 |
|
| 77 |
``` |
| 78 |
code |
| 79 |
``` |
| 80 |
''', |
| 81 |
r''' |
| 82 |
<div class="tabbed-set" data-tabs="1:2"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1"><strong>Tab</strong></label><div class="tabbed-content"> |
| 83 |
<p>Some <em>content</em></p> |
| 84 |
<p>And more <code>content</code>.</p> |
| 85 |
</div> |
| 86 |
<input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><label for="__tabbed_1_2"><em>Another Tab</em></label><div class="tabbed-content"> |
| 87 |
<p>Some more content.</p> |
| 88 |
<div class="highlight"><pre><span></span><code>code |
| 89 |
</code></pre></div> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
''', # noqa: E501 |
| 93 |
True |
| 94 |
) |
| 95 |
|
| 96 |
def test_nested_tabbed(self): |
| 97 |
"""Test nested tabbed.""" |
| 98 |
|
| 99 |
self.check_markdown( |
| 100 |
r''' |
| 101 |
=== "Tab" |
| 102 |
Some *content* |
| 103 |
|
| 104 |
=== "Tab A" |
| 105 |
- item 1 |
| 106 |
|
| 107 |
- item 2 |
| 108 |
|
| 109 |
=== "Tab B" |
| 110 |
- item A |
| 111 |
|
| 112 |
- item B |
| 113 |
|
| 114 |
=== "Another Tab" |
| 115 |
Some more content. |
| 116 |
''', |
| 117 |
r''' |
| 118 |
<div class="tabbed-set" data-tabs="1:2"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab</label><div class="tabbed-content"> |
| 119 |
<p>Some <em>content</em></p> |
| 120 |
<div class="tabbed-set" data-tabs="2:2"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><label for="__tabbed_2_1">Tab A</label><div class="tabbed-content"> |
| 121 |
<ul> |
| 122 |
<li> |
| 123 |
<p>item 1</p> |
| 124 |
</li> |
| 125 |
<li> |
| 126 |
<p>item 2</p> |
| 127 |
</li> |
| 128 |
</ul> |
| 129 |
</div> |
| 130 |
<input id="__tabbed_2_2" name="__tabbed_2" type="radio" /><label for="__tabbed_2_2">Tab B</label><div class="tabbed-content"> |
| 131 |
<ul> |
| 132 |
<li> |
| 133 |
<p>item A</p> |
| 134 |
</li> |
| 135 |
<li> |
| 136 |
<p>item B</p> |
| 137 |
</li> |
| 138 |
</ul> |
| 139 |
</div> |
| 140 |
</div> |
| 141 |
</div> |
| 142 |
<input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><label for="__tabbed_1_2">Another Tab</label><div class="tabbed-content"> |
| 143 |
<p>Some more content.</p> |
| 144 |
</div> |
| 145 |
</div> |
| 146 |
''', # noqa: E501 |
| 147 |
True |
| 148 |
) |
| 149 |
|
| 150 |
def test_tabbed_split(self): |
| 151 |
"""Force a split of tab sets.""" |
| 152 |
|
| 153 |
self.check_markdown( |
| 154 |
r''' |
| 155 |
=== "Tab" |
| 156 |
Some *content* |
| 157 |
|
| 158 |
And more `content`. |
| 159 |
|
| 160 |
===! "Another Tab" |
| 161 |
Some more content. |
| 162 |
|
| 163 |
``` |
| 164 |
code |
| 165 |
``` |
| 166 |
''', |
| 167 |
r''' |
| 168 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab</label><div class="tabbed-content"> |
| 169 |
<p>Some <em>content</em></p> |
| 170 |
<p>And more <code>content</code>.</p> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
<div class="tabbed-set" data-tabs="2:1"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><label for="__tabbed_2_1">Another Tab</label><div class="tabbed-content"> |
| 174 |
<p>Some more content.</p> |
| 175 |
<div class="highlight"><pre><span></span><code>code |
| 176 |
</code></pre></div> |
| 177 |
</div> |
| 178 |
</div> |
| 179 |
''', # noqa: E501 |
| 180 |
True |
| 181 |
) |
| 182 |
|
| 183 |
def test_tabbed_break(self): |
| 184 |
"""Test that tabs are properly terminated on blocks that are not under the tab.""" |
| 185 |
|
| 186 |
self.check_markdown( |
| 187 |
r''' |
| 188 |
=== "Tab" |
| 189 |
Some *content* |
| 190 |
|
| 191 |
And more `content`. |
| 192 |
Content |
| 193 |
''', |
| 194 |
r''' |
| 195 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab</label><div class="tabbed-content"> |
| 196 |
<p>Some <em>content</em></p> |
| 197 |
<p>And more <code>content</code>.</p> |
| 198 |
</div> |
| 199 |
</div> |
| 200 |
<p>Content</p> |
| 201 |
''', # noqa: E501 |
| 202 |
True |
| 203 |
) |
| 204 |
|
| 205 |
def test_tabbed_select(self): |
| 206 |
"""Test selecting a tab.""" |
| 207 |
|
| 208 |
self.check_markdown( |
| 209 |
r''' |
| 210 |
=== "Tab 1" |
| 211 |
content |
| 212 |
|
| 213 |
===+ "Tab 2" |
| 214 |
content |
| 215 |
|
| 216 |
=== "Tab 3" |
| 217 |
content |
| 218 |
''', |
| 219 |
r''' |
| 220 |
<div class="tabbed-set" data-tabs="1:3"><input id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab 1</label><div class="tabbed-content"> |
| 221 |
<p>content</p> |
| 222 |
</div> |
| 223 |
<input checked="checked" id="__tabbed_1_2" name="__tabbed_1" type="radio" /><label for="__tabbed_1_2">Tab 2</label><div class="tabbed-content"> |
| 224 |
<p>content</p> |
| 225 |
</div> |
| 226 |
<input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><label for="__tabbed_1_3">Tab 3</label><div class="tabbed-content"> |
| 227 |
<p>content</p> |
| 228 |
</div> |
| 229 |
</div> |
| 230 |
''', # noqa: E501 |
| 231 |
True |
| 232 |
) |
| 233 |
|
| 234 |
def test_tabbed_select_multiple(self): |
| 235 |
"""Test selecting multiple tabs.""" |
| 236 |
|
| 237 |
self.check_markdown( |
| 238 |
r''' |
| 239 |
=== "Tab 1" |
| 240 |
content |
| 241 |
|
| 242 |
===+ "Tab 2" |
| 243 |
content |
| 244 |
|
| 245 |
===+ "Tab 3" |
| 246 |
content |
| 247 |
''', |
| 248 |
r''' |
| 249 |
<div class="tabbed-set" data-tabs="1:3"><input id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab 1</label><div class="tabbed-content"> |
| 250 |
<p>content</p> |
| 251 |
</div> |
| 252 |
<input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><label for="__tabbed_1_2">Tab 2</label><div class="tabbed-content"> |
| 253 |
<p>content</p> |
| 254 |
</div> |
| 255 |
<input checked="checked" id="__tabbed_1_3" name="__tabbed_1" type="radio" /><label for="__tabbed_1_3">Tab 3</label><div class="tabbed-content"> |
| 256 |
<p>content</p> |
| 257 |
</div> |
| 258 |
</div> |
| 259 |
''', # noqa: E501 |
| 260 |
True |
| 261 |
) |
| 262 |
|
| 263 |
def test_with_lists(self): |
| 264 |
"""Test with lists.""" |
| 265 |
|
| 266 |
self.check_markdown( |
| 267 |
''' |
| 268 |
- List |
| 269 |
|
| 270 |
=== "Tab" |
| 271 |
|
| 272 |
- Paragraph |
| 273 |
|
| 274 |
Paragraph |
| 275 |
''', |
| 276 |
|
| 277 |
''' |
| 278 |
<ul> |
| 279 |
<li> |
| 280 |
<p>List</p> |
| 281 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab</label><div class="tabbed-content"> |
| 282 |
<ul> |
| 283 |
<li> |
| 284 |
<p>Paragraph</p> |
| 285 |
<p>Paragraph</p> |
| 286 |
</li> |
| 287 |
</ul> |
| 288 |
</div> |
| 289 |
</div> |
| 290 |
</li> |
| 291 |
</ul> |
| 292 |
''', # noqa: E501 |
| 293 |
True |
| 294 |
) |
| 295 |
|
| 296 |
def test_with_big_lists(self): |
| 297 |
"""Test details with a longer list.""" |
| 298 |
|
| 299 |
self.check_markdown( |
| 300 |
''' |
| 301 |
- List |
| 302 |
|
| 303 |
=== "Tab" |
| 304 |
|
| 305 |
- Paragraph |
| 306 |
|
| 307 |
Paragraph |
| 308 |
|
| 309 |
- Paragraph |
| 310 |
|
| 311 |
paragraph |
| 312 |
''', |
| 313 |
''' |
| 314 |
<ul> |
| 315 |
<li> |
| 316 |
<p>List</p> |
| 317 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab</label><div class="tabbed-content"> |
| 318 |
<ul> |
| 319 |
<li> |
| 320 |
<p>Paragraph</p> |
| 321 |
<p>Paragraph</p> |
| 322 |
</li> |
| 323 |
<li> |
| 324 |
<p>Paragraph</p> |
| 325 |
<p>paragraph</p> |
| 326 |
</li> |
| 327 |
</ul> |
| 328 |
</div> |
| 329 |
</div> |
| 330 |
</li> |
| 331 |
</ul> |
| 332 |
''', # noqa: E501 |
| 333 |
True |
| 334 |
) |
| 335 |
|
| 336 |
def test_with_complex_lists(self): |
| 337 |
"""Test details in a complex list scenario.""" |
| 338 |
|
| 339 |
self.check_markdown( |
| 340 |
''' |
| 341 |
- List |
| 342 |
|
| 343 |
=== "Tab" |
| 344 |
|
| 345 |
- Paragraph |
| 346 |
|
| 347 |
=== "Tab" |
| 348 |
|
| 349 |
1. Paragraph |
| 350 |
|
| 351 |
Paragraph |
| 352 |
''', |
| 353 |
''' |
| 354 |
<ul> |
| 355 |
<li> |
| 356 |
<p>List</p> |
| 357 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab</label><div class="tabbed-content"> |
| 358 |
<ul> |
| 359 |
<li> |
| 360 |
<p>Paragraph</p> |
| 361 |
<div class="tabbed-set" data-tabs="2:1"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><label for="__tabbed_2_1">Tab</label><div class="tabbed-content"> |
| 362 |
<ol> |
| 363 |
<li> |
| 364 |
<p>Paragraph</p> |
| 365 |
<p>Paragraph</p> |
| 366 |
</li> |
| 367 |
</ol> |
| 368 |
</div> |
| 369 |
</div> |
| 370 |
</li> |
| 371 |
</ul> |
| 372 |
</div> |
| 373 |
</div> |
| 374 |
</li> |
| 375 |
</ul> |
| 376 |
''', # noqa: E501 |
| 377 |
True |
| 378 |
) |
| 379 |
|
| 380 |
def test_definition_list(self): |
| 381 |
"""Test with definition list.""" |
| 382 |
|
| 383 |
self.check_markdown( |
| 384 |
''' |
| 385 |
- List |
| 386 |
|
| 387 |
=== "Tab" |
| 388 |
|
| 389 |
Term |
| 390 |
|
| 391 |
: Definition |
| 392 |
|
| 393 |
More text |
| 394 |
|
| 395 |
: Another |
| 396 |
definition |
| 397 |
|
| 398 |
Even more text |
| 399 |
''', |
| 400 |
''' |
| 401 |
<ul> |
| 402 |
<li> |
| 403 |
<p>List</p> |
| 404 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab</label><div class="tabbed-content"> |
| 405 |
<dl> |
| 406 |
<dt>Term</dt> |
| 407 |
<dd> |
| 408 |
<p>Definition</p> |
| 409 |
<p>More text</p> |
| 410 |
</dd> |
| 411 |
<dd> |
| 412 |
<p>Another |
| 413 |
definition</p> |
| 414 |
<p>Even more text</p> |
| 415 |
</dd> |
| 416 |
</dl> |
| 417 |
</div> |
| 418 |
</div> |
| 419 |
</li> |
| 420 |
</ul> |
| 421 |
''', # noqa: E501 |
| 422 |
True |
| 423 |
) |
| 424 |
|
| 425 |
def test_with_details(self): |
| 426 |
"""Test with definition list.""" |
| 427 |
|
| 428 |
self.check_markdown( |
| 429 |
''' |
| 430 |
=== "Output" |
| 431 |
???+ note "Open styled details" |
| 432 |
|
| 433 |
??? danger "Nested details!" |
| 434 |
And more content again. |
| 435 |
''', |
| 436 |
''' |
| 437 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Output</label><div class="tabbed-content"> |
| 438 |
<details class="note" open="open"> |
| 439 |
<summary>Open styled details</summary> |
| 440 |
<details class="danger"> |
| 441 |
<summary>Nested details!</summary> |
| 442 |
<p>And more content again.</p> |
| 443 |
</details> |
| 444 |
</details> |
| 445 |
</div> |
| 446 |
</div> |
| 447 |
''', # noqa: E501 |
| 448 |
True |
| 449 |
) |
| 450 |
|
| 451 |
def test_tabbed_complex_list(self): |
| 452 |
"""Test tabbed complex list scenario.""" |
| 453 |
|
| 454 |
self.check_markdown( |
| 455 |
''' |
| 456 |
=== "Tab with loose lists" |
| 457 |
- Parent 1 |
| 458 |
|
| 459 |
- Child 1 |
| 460 |
- Child 2 |
| 461 |
''', |
| 462 |
''' |
| 463 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab with loose lists</label><div class="tabbed-content"> |
| 464 |
<ul> |
| 465 |
<li> |
| 466 |
<p>Parent 1</p> |
| 467 |
<ul> |
| 468 |
<li>Child 1</li> |
| 469 |
<li>Child 2</li> |
| 470 |
</ul> |
| 471 |
</li> |
| 472 |
</ul> |
| 473 |
</div> |
| 474 |
</div> |
| 475 |
''', # noqa: E501 |
| 476 |
True |
| 477 |
) |
| 478 |
|
| 479 |
def test_tabbed_complex_list_unindented_content(self): |
| 480 |
"""Test tabbed complex list scenario with un-indented content.""" |
| 481 |
|
| 482 |
self.check_markdown( |
| 483 |
''' |
| 484 |
=== "Tab with loose lists" |
| 485 |
- Parent 1 |
| 486 |
|
| 487 |
- Child 1 |
| 488 |
- Child 2 |
| 489 |
- Parent 2 |
| 490 |
''', |
| 491 |
''' |
| 492 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab with loose lists</label><div class="tabbed-content"> |
| 493 |
<ul> |
| 494 |
<li> |
| 495 |
<p>Parent 1</p> |
| 496 |
<ul> |
| 497 |
<li>Child 1</li> |
| 498 |
<li>Child 2</li> |
| 499 |
</ul> |
| 500 |
</li> |
| 501 |
</ul> |
| 502 |
</div> |
| 503 |
</div> |
| 504 |
<ul> |
| 505 |
<li>Parent 2</li> |
| 506 |
</ul> |
| 507 |
''', # noqa: E501 |
| 508 |
True |
| 509 |
) |
| 510 |
|
| 511 |
def test_indented_code(self): |
| 512 |
"""Test indented code.""" |
| 513 |
|
| 514 |
md = """ |
| 515 |
=== "Tab 1" |
| 516 |
|
| 517 |
code |
| 518 |
""" |
| 519 |
|
| 520 |
self.check_markdown( |
| 521 |
md, |
| 522 |
''' |
| 523 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Tab 1</label><div class="tabbed-content"> |
| 524 |
<pre><code>code |
| 525 |
</code></pre> |
| 526 |
</div> |
| 527 |
</div> |
| 528 |
''', # noqa: E501 |
| 529 |
True |
| 530 |
) |
| 531 |
|
| 532 |
def test_empty_title(self): |
| 533 |
"""Test empty title.""" |
| 534 |
|
| 535 |
md = R""" |
| 536 |
=== "" |
| 537 |
Content |
| 538 |
""" |
| 539 |
|
| 540 |
self.check_markdown( |
| 541 |
md, |
| 542 |
''' |
| 543 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1"></label><div class="tabbed-content"> |
| 544 |
<p>Content</p> |
| 545 |
</div> |
| 546 |
</div> |
| 547 |
''', # noqa: E501 |
| 548 |
True |
| 549 |
) |
| 550 |
|
| 551 |
|
| 552 |
class TestLegacyTabSlugs(util.MdCase): |
| 553 |
"""Test legacy tab slug cases.""" |
| 554 |
|
| 555 |
extension = ['pymdownx.tabbed', 'toc'] |
| 556 |
extension_configs = {'pymdownx.tabbed': {'slugify': slugify(case='lower')}} |
| 557 |
|
| 558 |
MD = """ |
| 559 |
### Here is some text |
| 560 |
|
| 561 |
=== "Here is some text" |
| 562 |
content |
| 563 |
|
| 564 |
=== "Here is some text" |
| 565 |
content |
| 566 |
""" |
| 567 |
|
| 568 |
def test_tab_slugs(self): |
| 569 |
"""Test tab slugs.""" |
| 570 |
|
| 571 |
self.check_markdown( |
| 572 |
self.MD, |
| 573 |
''' |
| 574 |
<h3 id="here-is-some-text">Here is some text</h3> |
| 575 |
<div class="tabbed-set" data-tabs="1:2"><input checked="checked" id="here-is-some-text_1" name="__tabbed_1" type="radio" /><label for="here-is-some-text_1">Here is some text</label><div class="tabbed-content"> |
| 576 |
<p>content</p> |
| 577 |
</div> |
| 578 |
<input id="here-is-some-text_2" name="__tabbed_1" type="radio" /><label for="here-is-some-text_2">Here is some text</label><div class="tabbed-content"> |
| 579 |
<p>content</p> |
| 580 |
</div> |
| 581 |
</div> |
| 582 |
''', # noqa: E501 |
| 583 |
True |
| 584 |
) |
| 585 |
|
| 586 |
|
| 587 |
class TestLegacyTabSlugsSep(util.MdCase): |
| 588 |
"""Test legacy tab slug separator cases.""" |
| 589 |
|
| 590 |
extension = ['pymdownx.tabbed', 'toc'] |
| 591 |
extension_configs = {'pymdownx.tabbed': {'slugify': slugify(case='lower'), 'separator': '_'}} |
| 592 |
|
| 593 |
MD = """ |
| 594 |
### Here is some text |
| 595 |
|
| 596 |
=== "Here is some text" |
| 597 |
content |
| 598 |
|
| 599 |
=== "Here is some text" |
| 600 |
content |
| 601 |
""" |
| 602 |
|
| 603 |
def test_slug_with_separator(self): |
| 604 |
"""Test tab slugs with separator.""" |
| 605 |
|
| 606 |
self.check_markdown( |
| 607 |
self.MD, |
| 608 |
''' |
| 609 |
<h3 id="here-is-some-text">Here is some text</h3> |
| 610 |
<div class="tabbed-set" data-tabs="1:2"><input checked="checked" id="here_is_some_text" name="__tabbed_1" type="radio" /><label for="here_is_some_text">Here is some text</label><div class="tabbed-content"> |
| 611 |
<p>content</p> |
| 612 |
</div> |
| 613 |
<input id="here_is_some_text_1" name="__tabbed_1" type="radio" /><label for="here_is_some_text_1">Here is some text</label><div class="tabbed-content"> |
| 614 |
<p>content</p> |
| 615 |
</div> |
| 616 |
</div> |
| 617 |
''', # noqa: E501 |
| 618 |
True |
| 619 |
) |
| 620 |
|
| 621 |
|
| 622 |
class TestTabSlugsCombineHeader(util.MdCase): |
| 623 |
"""Combine header slug with content tab.""" |
| 624 |
|
| 625 |
extension = ['pymdownx.tabbed', 'toc', 'pymdownx.details'] |
| 626 |
extension_configs = { |
| 627 |
'pymdownx.tabbed': { |
| 628 |
'slugify': slugify(case='lower'), |
| 629 |
'combine_header_slug': True |
| 630 |
} |
| 631 |
} |
| 632 |
|
| 633 |
def test_combine_header_slug(self): |
| 634 |
"""Test that slugs are a combination of the header slug and the tab title.""" |
| 635 |
|
| 636 |
md = R""" |
| 637 |
### Here is some text |
| 638 |
|
| 639 |
=== "First Tab" |
| 640 |
content |
| 641 |
|
| 642 |
### Another header |
| 643 |
|
| 644 |
??? "title" |
| 645 |
=== "Second Tab" |
| 646 |
content |
| 647 |
""" |
| 648 |
|
| 649 |
self.check_markdown( |
| 650 |
md, |
| 651 |
''' |
| 652 |
<h3 id="here-is-some-text">Here is some text</h3> |
| 653 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="here-is-some-text-first-tab" name="__tabbed_1" type="radio" /><label for="here-is-some-text-first-tab">First Tab</label><div class="tabbed-content"> |
| 654 |
<p>content</p> |
| 655 |
</div> |
| 656 |
</div> |
| 657 |
<h3 id="another-header">Another header</h3> |
| 658 |
<details> |
| 659 |
<summary>title</summary> |
| 660 |
<div class="tabbed-set" data-tabs="2:1"><input checked="checked" id="another-header-second-tab" name="__tabbed_2" type="radio" /><label for="another-header-second-tab">Second Tab</label><div class="tabbed-content"> |
| 661 |
<p>content</p> |
| 662 |
</div> |
| 663 |
</div> |
| 664 |
</details> |
| 665 |
''', # noqa: E501 |
| 666 |
True |
| 667 |
) |
| 668 |
|
| 669 |
def test_no_header(self): |
| 670 |
"""Test when there is no header.""" |
| 671 |
|
| 672 |
md = R""" |
| 673 |
=== "A Tab" |
| 674 |
content |
| 675 |
""" |
| 676 |
|
| 677 |
self.check_markdown( |
| 678 |
md, |
| 679 |
''' |
| 680 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="a-tab" name="__tabbed_1" type="radio" /><label for="a-tab">A Tab</label><div class="tabbed-content"> |
| 681 |
<p>content</p> |
| 682 |
</div> |
| 683 |
</div> |
| 684 |
''', # noqa: E501 |
| 685 |
True |
| 686 |
) |
| 687 |
|
| 688 |
def test_header_after(self): |
| 689 |
"""Test when header comes after.""" |
| 690 |
|
| 691 |
md = R""" |
| 692 |
=== "A Tab" |
| 693 |
content |
| 694 |
|
| 695 |
# Header |
| 696 |
""" |
| 697 |
|
| 698 |
self.check_markdown( |
| 699 |
md, |
| 700 |
''' |
| 701 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="a-tab" name="__tabbed_1" type="radio" /><label for="a-tab">A Tab</label><div class="tabbed-content"> |
| 702 |
<p>content</p> |
| 703 |
</div> |
| 704 |
</div> |
| 705 |
<h1 id="header">Header</h1> |
| 706 |
''', # noqa: E501 |
| 707 |
True |
| 708 |
) |
| 709 |
|
| 710 |
def test_empty_title(self): |
| 711 |
"""Test empty title.""" |
| 712 |
|
| 713 |
md = R""" |
| 714 |
=== "" |
| 715 |
Content |
| 716 |
""" |
| 717 |
|
| 718 |
self.check_markdown( |
| 719 |
md, |
| 720 |
''' |
| 721 |
<div class="tabbed-set" data-tabs="1:1"><input checked="checked" id="_1" name="__tabbed_1" type="radio" /><label for="_1"></label><div class="tabbed-content"> |
| 722 |
<p>Content</p> |
| 723 |
</div> |
| 724 |
</div> |
| 725 |
''', # noqa: E501 |
| 726 |
True |
| 727 |
) |