Place TOC after page-lead; stop prepending TOC above intro
Fix TOC placement: ignore Contents heading inside #toc
Line 241: Line 241:
$ibox.after($toc);
$ibox.after($toc);
} else {
} else {
var $firstH2 = $out.find('h2').first();
// Never use the TOC's own "Contents" heading (h2 inside #toc).
var $firstH2 = $out.find('h2').filter(function () {
return !$(this).closest('#toc, .toc, .mw-table-of-contents').length;
}).first();
if ($firstH2.length) {
if ($firstH2.length) {
$firstH2.before($toc);
$firstH2.before($toc);