From: Leo Koppelkamm Date: Thu, 14 Apr 2011 10:02:51 +0000 (+0000) Subject: Fixing line-break issues with r85922 X-Git-Tag: 1.31.0-rc.0~30857 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=3dde00f86374bde9840b40af9595402160e176a6;p=lhc%2Fweb%2Fwiklou.git Fixing line-break issues with r85922 --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index a3043ebe25..f3ba2b53f8 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -829,8 +829,13 @@ class Parser { foreach ( $lines as $outLine ) { $line = trim( $outLine ); - if ( $line === '' ) { // empty line, go to next line - $out .= $outLine . "\n"; + # empty line, go to next line, + # but only append \n if outside of table + if ( $line === '' ) { + $out .= $outLine; + if ( !isset( $tables[0] ) ) { + $out .= "\n"; + } continue; } $firstChars = $line[0]; @@ -877,8 +882,14 @@ class Parser { if ( empty( $lastRow ) ) { $lastRow = NULL; } + $o = ''; $curtable = array_pop( $tables ); - $o = $this->generateTableHTML( $curtable ) . $line; + + #Add a line-ending before the table, but only if there isn't one already + if ( substr( $out, -1 ) !== "\n" ) { + $o .= "\n"; + } + $o .= $this->generateTableHTML( $curtable ) . $line . "\n"; if ( count( $tables ) > 0 ) { $table =& $this->last( $tables ); @@ -968,7 +979,12 @@ class Parser { if ( isset( $tables ) && count( $tables ) > 0 ) { for ( $i = 0; $i < count( $tables ); $i++ ) { $curtable = array_pop( $tables ); - $out .= $this->generateTableHTML( $curtable ); + $curtable = $this->generateTableHTML( $curtable ); + #Add a line-ending before the table, but only if there isn't one already + if ( substr( $out, -1 ) !== "\n" && $curtable !== "" ) { + $out .= "\n"; + } + $out .= $curtable; } } @@ -1018,7 +1034,7 @@ class Parser { * @private */ function generateTableHTML ( &$table ) { - $return = "\n"; + $return = ""; $return .= str_repeat( '
' , $table['indent'] ); $return .= '
!! end + +!! test +Arbitrary whitespace should not be prepended +!! input +{| +| 1 || 2 + +|- + + +| 3 || 4 +|- + +| 6 || 8 +|} +!! result + + + + + + + + + + + + + +
1 +2 +
3 +4 +
6 +8 +
+ +!! end + + ### ### Internal links ### @@ -5693,7 +5733,6 @@ http://===r:::https://b !!result

http://===r:::https://b

- !! end # Known to produce bad XML for now @@ -5731,8 +5770,7 @@ MOVE YOUR MOUSE CURSOR OVER THIS TEXT

{{{|

}}}} >


-


-MOVE YOUR MOUSE CURSOR OVER THIS TEXT +

MOVE YOUR MOUSE CURSOR OVER THIS TEXT

@@ -7918,7 +7956,8 @@ y -
4
+ +

y

!! end