Index: branches/REL1_10/phase3/maintenance/parserTests.txt |
— | — | @@ -3370,6 +3370,44 @@ |
3371 | 3371 | !! end |
3372 | 3372 | |
3373 | 3373 | !! test |
| 3374 | +TOC regression (bug 9764) |
| 3375 | +!! input |
| 3376 | +== title 1 == |
| 3377 | +=== title 1.1 === |
| 3378 | +==== title 1.1.1 ==== |
| 3379 | +=== title 1.2 === |
| 3380 | +== title 2 == |
| 3381 | +=== title 2.1 === |
| 3382 | +!! result |
| 3383 | +<table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div> |
| 3384 | +<ul> |
| 3385 | +<li class="toclevel-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a> |
| 3386 | +<ul> |
| 3387 | +<li class="toclevel-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a> |
| 3388 | +<ul> |
| 3389 | +<li class="toclevel-3"><a href="#title_1.1.1"><span class="tocnumber">1.1.1</span> <span class="toctext">title 1.1.1</span></a></li> |
| 3390 | +</ul> |
| 3391 | +</li> |
| 3392 | +<li class="toclevel-2"><a href="#title_1.2"><span class="tocnumber">1.2</span> <span class="toctext">title 1.2</span></a></li> |
| 3393 | +</ul> |
| 3394 | +</li> |
| 3395 | +<li class="toclevel-1"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a> |
| 3396 | +<ul> |
| 3397 | +<li class="toclevel-2"><a href="#title_2.1"><span class="tocnumber">2.1</span> <span class="toctext">title 2.1</span></a></li> |
| 3398 | +</ul> |
| 3399 | +</li> |
| 3400 | +</ul> |
| 3401 | +</td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script> |
| 3402 | +<a name="title_1"></a><h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a>]</span> <span class="mw-headline"> title 1 </span></h2> |
| 3403 | +<a name="title_1.1"></a><h3><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a>]</span> <span class="mw-headline"> title 1.1 </span></h3> |
| 3404 | +<a name="title_1.1.1"></a><h4><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 1.1.1">edit</a>]</span> <span class="mw-headline"> title 1.1.1 </span></h4> |
| 3405 | +<a name="title_1.2"></a><h3><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=4" title="Edit section: title 1.2">edit</a>]</span> <span class="mw-headline"> title 1.2 </span></h3> |
| 3406 | +<a name="title_2"></a><h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=5" title="Edit section: title 2">edit</a>]</span> <span class="mw-headline"> title 2 </span></h2> |
| 3407 | +<a name="title_2.1"></a><h3><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=6" title="Edit section: title 2.1">edit</a>]</span> <span class="mw-headline"> title 2.1 </span></h3> |
| 3408 | + |
| 3409 | +!! end |
| 3410 | + |
| 3411 | +!! test |
3374 | 3412 | Resolving duplicate section names |
3375 | 3413 | !! input |
3376 | 3414 | == Foo bar == |
Index: branches/REL1_10/phase3/includes/Parser.php |
— | — | @@ -3453,13 +3453,17 @@ |
3454 | 3454 | $enoughToc = true; |
3455 | 3455 | } |
3456 | 3456 | |
| 3457 | + # Never ever show TOC if no headers |
| 3458 | + if( $numMatches < 1 ) { |
| 3459 | + $enoughToc = false; |
| 3460 | + } |
| 3461 | + |
3457 | 3462 | # We need this to perform operations on the HTML |
3458 | 3463 | $sk = $this->mOptions->getSkin(); |
3459 | 3464 | |
3460 | 3465 | # headline counter |
3461 | 3466 | $headlineCount = 0; |
3462 | 3467 | $sectionCount = 0; # headlineCount excluding template sections |
3463 | | - $numVisible = 0; |
3464 | 3468 | |
3465 | 3469 | # Ugh .. the TOC should have neat indentation levels which can be |
3466 | 3470 | # passed to the skin functions. These are determined here |
— | — | @@ -3489,6 +3493,7 @@ |
3490 | 3494 | |
3491 | 3495 | if( $toclevel ) { |
3492 | 3496 | $prevlevel = $level; |
| 3497 | + $prevtoclevel = $toclevel; |
3493 | 3498 | } |
3494 | 3499 | $level = $matches[1][$headlineCount]; |
3495 | 3500 | |
— | — | @@ -3499,9 +3504,7 @@ |
3500 | 3505 | $toclevel++; |
3501 | 3506 | $sublevelCount[$toclevel] = 0; |
3502 | 3507 | if( $toclevel<$wgMaxTocLevel ) { |
3503 | | - $prevtoclevel = $toclevel; |
3504 | 3508 | $toc .= $sk->tocIndent(); |
3505 | | - $numVisible++; |
3506 | 3509 | } |
3507 | 3510 | } |
3508 | 3511 | elseif ( $level < $prevlevel && $toclevel > 1 ) { |
— | — | @@ -3608,14 +3611,9 @@ |
3609 | 3612 | $sectionCount++; |
3610 | 3613 | } |
3611 | 3614 | |
3612 | | - # Never ever show TOC if no headers |
3613 | | - if( $numVisible < 1 ) { |
3614 | | - $enoughToc = false; |
3615 | | - } |
3616 | | - |
3617 | 3615 | if( $enoughToc ) { |
3618 | | - if( $prevtoclevel > 0 && $prevtoclevel < $wgMaxTocLevel ) { |
3619 | | - $toc .= $sk->tocUnindent( $prevtoclevel - 1 ); |
| 3616 | + if( $toclevel<$wgMaxTocLevel ) { |
| 3617 | + $toc .= $sk->tocUnindent( $toclevel - 1 ); |
3620 | 3618 | } |
3621 | 3619 | $toc = $sk->tocList( $toc ); |
3622 | 3620 | } |
Index: branches/REL1_10/phase3/RELEASE-NOTES |
— | — | @@ -377,10 +377,6 @@ |
378 | 378 | * (bug 8602) Converted Special:Contributions to use an IndexPager. The |
379 | 379 | interpretation of the offset parameter has changed, and the go parameter |
380 | 380 | has been removed. |
381 | | -* (bug 6204) Fixes for indentation with $wgMaxTocLevel: |
382 | | - - don't emit too many list close tags after an invisible header |
383 | | - - don't emit too many final list close tags if last header is invisible |
384 | | - - don't emit TOC when there are no visible headers |
385 | 381 | * (bug 7629) Fix $wgBrowserBlackList to avoid false positive on MSIE |
386 | 382 | when certain plugins are present which alter the user agent |
387 | 383 | |