Index: trunk/phase3/includes/Parser.php |
— | — | @@ -317,7 +317,7 @@ |
318 | 318 | $fc = substr ( $x , 0 , 1 ) ; |
319 | 319 | if ( "{|" == substr ( $x , 0 , 2 ) ) |
320 | 320 | { |
321 | | - $t[$k] = "<table " . $this->fixTagAttributes ( substr ( $x , 3 ) ) . ">" ; |
| 321 | + $t[$k] = "\n<table " . $this->fixTagAttributes ( substr ( $x , 3 ) ) . ">" ; |
322 | 322 | array_push ( $td , false ) ; |
323 | 323 | array_push ( $ltd , "" ) ; |
324 | 324 | array_push ( $tr , false ) ; |
— | — | @@ -420,7 +420,6 @@ |
421 | 421 | $text = str_replace ( "<HR>", "<hr />", $text ); |
422 | 422 | |
423 | 423 | $text = $this->doHeadings( $text ); |
424 | | - $text = $this->doBlockLevels( $text, $linestart ); |
425 | 424 | |
426 | 425 | if($this->mOptions->getUseDynamicDates()) { |
427 | 426 | global $wgDateFormatter; |
— | — | @@ -435,6 +434,7 @@ |
436 | 435 | |
437 | 436 | $sk =& $this->mOptions->getSkin(); |
438 | 437 | $text = $sk->transformContent( $text ); |
| 438 | + $text = $this->doBlockLevels( $text, $linestart ); |
439 | 439 | $text .= $this->categoryMagic () ; |
440 | 440 | |
441 | 441 | wfProfileOut( $fname ); |
— | — | @@ -887,7 +887,7 @@ |
888 | 888 | /* private */ function closeParagraph() |
889 | 889 | { |
890 | 890 | $result = ""; |
891 | | - if ( 0 != strcmp( "", $this->mLastSection ) ) { |
| 891 | + if ( '' != $this->mLastSection ) { |
892 | 892 | $result = "</" . $this->mLastSection . ">"; |
893 | 893 | } |
894 | 894 | $this->mLastSection = ""; |
— | — | @@ -968,8 +968,8 @@ |
969 | 969 | # and making lists from lines starting with * # : etc. |
970 | 970 | # |
971 | 971 | $a = explode( "\n", $text ); |
972 | | - $text = "<p>"; # ?? |
973 | | - $lastPref = ""; |
| 972 | + $a[0] = "\n".$a[0]; |
| 973 | + $lastPref = $text = ''; |
974 | 974 | $this->mDTopen = $inBlockElem = false; |
975 | 975 | |
976 | 976 | if ( ! $linestart ) { $text .= array_shift( $a ); } |
— | — | @@ -1022,32 +1022,36 @@ |
1023 | 1023 | } |
1024 | 1024 | if ( 0 == $npl ) { # No prefix--go to paragraph mode |
1025 | 1025 | if ( preg_match( |
1026 | | - "/(<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<p)/i", $t ) ) { |
| 1026 | + "/(<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<div|<pre)/i", $t ) ) { |
1027 | 1027 | $text .= $this->closeParagraph(); |
1028 | 1028 | $inBlockElem = true; |
| 1029 | + } else if ( preg_match("/(<hr)/i", $t ) ) { |
| 1030 | + $text .= $this->closeParagraph(); |
| 1031 | + $inBlockElem = false; |
1029 | 1032 | } |
1030 | 1033 | if ( ! $inBlockElem ) { |
1031 | 1034 | if ( " " == $t{0} ) { |
1032 | 1035 | $newSection = "pre"; |
1033 | 1036 | # $t = wfEscapeHTML( $t ); |
1034 | | - } else { |
1035 | | - $newSection = "p"; |
1036 | 1037 | } |
| 1038 | + else { $newSection = "p"; } |
1037 | 1039 | |
1038 | | - if ( 0 == strcmp( "", trim( $oLine ) ) ) { |
1039 | | - $text .= $this->closeParagraph(); |
1040 | | - $text .= "<" . $newSection . ">"; |
1041 | | - } else if ( 0 != strcmp( $this->mLastSection, |
1042 | | - $newSection ) ) { |
1043 | | - $text .= $this->closeParagraph(); |
1044 | | - if ( 0 != strcmp( "p", $newSection ) ) { |
| 1040 | + if ( '' == trim( $oLine ) ) { |
| 1041 | + if ( $this->mLastSection != 'p') { |
| 1042 | + $text .= $this->closeParagraph(); |
1045 | 1043 | $text .= "<" . $newSection . ">"; |
| 1044 | + $this->mLastSection = $newSection; |
| 1045 | + } else if ( $this->mLastSection == 'p') { |
| 1046 | + $text .= '<br />'; |
1046 | 1047 | } |
| 1048 | + } else if ( $this->mLastSection == $newSection and $newSection != 'p' ) { |
| 1049 | + $text .= $this->closeParagraph(); |
| 1050 | + $text .= "<" . $newSection . ">"; |
| 1051 | + $this->mLastSection = $newSection; |
1047 | 1052 | } |
1048 | | - $this->mLastSection = $newSection; |
1049 | 1053 | } |
1050 | 1054 | if ( $inBlockElem && |
1051 | | - preg_match( "/(<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|<\\/p)/i", $t ) ) { |
| 1055 | + preg_match( "/(<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|<\\/p<\\/div|<\\/pre)/i", $t ) ) { |
1052 | 1056 | $inBlockElem = false; |
1053 | 1057 | } |
1054 | 1058 | } |
— | — | @@ -1269,7 +1273,7 @@ |
1270 | 1274 | "ruby", "rt" , "rb" , "rp", "p" |
1271 | 1275 | ); |
1272 | 1276 | $htmlsingle = array( |
1273 | | - "br", "hr", "li", "dt", "dd", "hr/" |
| 1277 | + "br", "hr", "li", "dt", "dd" |
1274 | 1278 | ); |
1275 | 1279 | $htmlnest = array( # Tags that can be nested--?? |
1276 | 1280 | "table", "tr", "td", "th", "div", "blockquote", "ol", "ul", |
— | — | @@ -1465,8 +1469,7 @@ |
1466 | 1470 | $canonized_headline = preg_replace( "/<.*?" . ">/","",$canonized_headline ); |
1467 | 1471 | |
1468 | 1472 | $tocline = trim( $canonized_headline ); |
1469 | | - $canonized_headline = str_replace( '"', "", $canonized_headline ); |
1470 | | - $canonized_headline = str_replace( " ", "_", trim( $canonized_headline) ); |
| 1473 | + $canonized_headline = preg_replace( "/[^a-z0-9]/i", "_", trim( $canonized_headline ) ); |
1471 | 1474 | $refer[$headlineCount] = $canonized_headline; |
1472 | 1475 | |
1473 | 1476 | # count how many in assoc. array so we can track dupes in anchors |
— | — | @@ -1499,25 +1502,14 @@ |
1500 | 1503 | } |
1501 | 1504 | $head[$headlineCount] .= $sk->editSectionLink($headlineCount+1); |
1502 | 1505 | } |
1503 | | - |
1504 | | - |
1505 | | - # the headline might have a link |
1506 | | - if( preg_match( "/(.*)<a(.*)/", $headline, $headlinematches ) ) { |
1507 | | - # if so give an anchor name to the already existent link |
1508 | | - $headline = $headlinematches[1] |
1509 | | - . "<a name=\"$anchor\" " . $headlinematches[2]; |
1510 | | - } else { |
1511 | | - # else create an anchor link for the headline |
1512 | | - $headline = "<a name=\"$anchor\">$headline</a>"; |
1513 | | - } |
1514 | 1506 | |
1515 | | - # give headline the correct <h#> tag |
1516 | | - @$head[$headlineCount] .= "<h".$level.$matches[2][$headlineCount] .$headline."</h".$level.">"; |
1517 | | - |
1518 | | - # Add the edit section link |
| 1507 | + # Add the edit section span |
1519 | 1508 | if( $rightClickHack ) { |
1520 | | - $head[$headlineCount] = $sk->editSectionScript($headlineCount+1,$head[$headlineCount]); |
| 1509 | + $headline = $sk->editSectionScript($headlineCount+1,$headline); |
1521 | 1510 | } |
| 1511 | + |
| 1512 | + # give headline the correct <h#> tag |
| 1513 | + @$head[$headlineCount] .= "<a name=\"$anchor\"></a><h".$level.$matches[2][$headlineCount] .$headline."</h".$level.">"; |
1522 | 1514 | |
1523 | 1515 | $headlineCount++; |
1524 | 1516 | } |