* (bug 12077) Fix HTML nesting for TOC
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 24 Mar 2008 23:33:31 +0000 (23:33 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 24 Mar 2008 23:33:31 +0000 (23:33 +0000)
Patch by WTucker at https://bugzilla.wikimedia.org/show_bug.cgi?id=12077#c5
Plus parser test case

RELEASE-NOTES
includes/Parser.php
maintenance/parserTests.txt

index 45b3bca..cb671fc 100644 (file)
@@ -128,6 +128,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 11874) Inline CSS with !important no longer borken
 * (bug 1600) Strip extra == section markup == in new-comment field
 * (bug 11325) Wrapped page titles in MonoBook skin spaced more nicely
+* (bug 12077) Fix HTML nesting for TOC
 
 
 === API changes in 1.13 ===
index 86e90ce..64ebdc8 100644 (file)
@@ -3437,6 +3437,7 @@ class Parser
                                                if($prevtoclevel < $wgMaxTocLevel) {
                                                        # Unindent only if the previous toc level was shown :p
                                                        $toc .= $sk->tocUnindent( $prevtoclevel - $toclevel );
+                                                       $prevtoclevel = $toclevel;
                                                } else {
                                                        $toc .= $sk->tocLineEnd();
                                                }
index a8ca7d9..109407e 100644 (file)
@@ -3605,6 +3605,29 @@ Link inside a section heading
 
 !! end
 
+!! test
+TOC regression (bug 12077)
+!! input
+__TOC__
+== title 1 ==
+=== title 1.1 ===
+== title 2 ==
+!! result
+<table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
+<ul>
+<li class="toclevel-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
+<ul>
+<li class="toclevel-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a></li>
+</ul>
+</li>
+<li class="toclevel-1"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
+</ul>
+</td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
+<a name="title_1"></a><h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: title 1">edit</a>]</span> <span class="mw-headline"> title 1 </span></h2>
+<a name="title_1.1"></a><h3><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: title 1.1">edit</a>]</span> <span class="mw-headline"> title 1.1 </span></h3>
+<a name="title_2"></a><h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: title 2">edit</a>]</span> <span class="mw-headline"> title 2 </span></h2>
+
+!! end
 
 !! test
 BUG 1219 URL next to image (good)