Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -3682,7 +3682,7 @@ |
3683 | 3683 | if( !empty( $head[$i] ) ) { # if there's no next header, then don't try to close out any existing sections here |
3684 | 3684 | # get the level of the next header section |
3685 | 3685 | preg_match('/<H([0-6])/i', $head[$i], $hLevelMatches); |
3686 | | - |
| 3686 | + |
3687 | 3687 | if ( count($hLevelMatches) > 0 ) { |
3688 | 3688 | $hLevel = $hLevelMatches[1]; |
3689 | 3689 | if ( $i != 0 ) { # we don't have an open div for section 0, so don't try to close it |
— | — | @@ -3701,7 +3701,7 @@ |
3702 | 3702 | |
3703 | 3703 | # if we've outputed the last section of the article, close any open divs that are remaining |
3704 | 3704 | if ( $i == ( count($blocks) - 1) && isset($currentHLevel) ) { |
3705 | | - $this->closeSectionContainers( $hLevel, $currentHLevel, $full, $openDivs); |
| 3705 | + $this->closeSectionContainers( $hLevel, $currentHLevel, $full, $openDivs, true); |
3706 | 3706 | } |
3707 | 3707 | } |
3708 | 3708 | |
— | — | @@ -3727,8 +3727,8 @@ |
3728 | 3728 | * @param array $openDivs a reference to the array that stores a list of open section containers |
3729 | 3729 | * @return true |
3730 | 3730 | */ |
3731 | | - function closeSectionContainers( $hLevel, &$currentHLevel, &$full, &$openDivs) { |
3732 | | - while ( $hLevel <= $currentHLevel ) { |
| 3731 | + function closeSectionContainers( $hLevel, &$currentHLevel, &$full, &$openDivs, $lastCall=false) { |
| 3732 | + while ( $hLevel <= $currentHLevel || $lastCall) { |
3733 | 3733 | $full .= '</div>'; |
3734 | 3734 | $popped = array_pop($openDivs); |
3735 | 3735 | if ( count($openDivs) ) { |