From 3e14e94db3013c066755484c8672c365234788c0 Mon Sep 17 00:00:00 2001 From: Gabriel Wicke Date: Fri, 9 Apr 2004 13:40:50 +0000 Subject: [PATCH] * no empty paragraphs anymore, two blank lines give a


now. * removed $inBlockElem = false bug * same in formatHeadings * Todo: stack for nestable block levels --- includes/Parser.php | 62 ++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 198c84dab4..e8e4c4ecc5 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -446,9 +446,10 @@ class Parser ); $text = preg_replace( array_keys($fixtags), array_values($fixtags), $text ); + $text .= $this->categoryMagic () ; + # needs to be called last $text = $this->doBlockLevels( $text, $linestart ); - $text .= $this->categoryMagic () ; wfProfileOut( $fname ); return $text; @@ -900,10 +901,10 @@ class Parser { $result = ""; if ( '' != $this->mLastSection ) { - $result = "mLastSection . ">"; + $result = "mLastSection . ">\n"; } $this->mLastSection = ""; - return $result."\n"; + return $result; } # getCommon() returns the length of the longest common substring # of both arguments, starting at the beginning of both. @@ -980,7 +981,7 @@ class Parser # and making lists from lines starting with * # : etc. # $a = explode( "\n", $text ); - $lastPref = $text = ''; + $lastPref = $text = $lastLine = ''; $this->mDTopen = $inBlockElem = false; if ( ! $linestart ) { $text .= array_shift( $a ); } @@ -1033,34 +1034,44 @@ class Parser } if ( 0 == $npl ) { # No prefix--go to paragraph mode $uniq_prefix = UNIQ_PREFIX; - $inBlockElem=false; - if ( preg_match( - "/(closeParagraph(); - $inBlockElem = true; - } else if ( preg_match("/(closeParagraph(); - $inBlockElem = false; - } - if ( !$inBlockElem ) { + if ( !$closematch ) { + $inBlockElem = true; + } else { + $inBlockElem = false; + } + } else if ( !$inBlockElem ) { if ( " " == $t{0} ) { $newSection = "pre"; - $text .= $this->closeParagraph(); - # $t = wfEscapeHTML( $t ); - } - else { $newSection = "p"; } - - if ( ( '' == trim( $oLine ) ) || ( $this->mLastSection == $newSection and $newSection != 'p' )) { $text .= $this->closeParagraph(); $text .= "<" . $newSection . ">"; $this->mLastSection = $newSection; - } - } - if ( $inBlockElem && - preg_match( "/(<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|<\\/p<\\/div)/i", $t ) ) { - $inBlockElem = false; - } + } else { + $newSection = "p"; + if ( '' == $oLine ) { + if ( '' == $lastLine ) { + $text .= $this->closeParagraph(); + $text .= "<" . $newSection . ">
"; + $this->mLastSection = $newSection; + } else { + $t = ''; + } + } else { + $text .= $this->closeParagraph(); + $text .= "<" . $newSection . ">"; + $this->mLastSection = $newSection; + } + } + + } } + $lastLine = $t; $text .= $t; } while ( $npl ) { @@ -1426,7 +1437,6 @@ class Parser /* private */ function formatHeadings( $text ) { - return $text; $doNumberHeadings = $this->mOptions->getNumberHeadings(); $doShowToc = $this->mOptions->getShowToc(); if( !$this->mTitle->userCanEdit() ) { -- 2.20.1