Index: trunk/phase3/includes/Parser.php |
— | — | @@ -2497,7 +2497,7 @@ |
2498 | 2498 | preg_match_all( '/<onlyinclude>(.*?)<\/onlyinclude>/s', $text, $m ); |
2499 | 2499 | $text = ''; |
2500 | 2500 | foreach ($m[1] as $piece) |
2501 | | - $text .= $piece; |
| 2501 | + $text .= $this->trimOnlyinclude( $piece ); |
2502 | 2502 | } |
2503 | 2503 | # Remove <noinclude> sections and <includeonly> tags |
2504 | 2504 | $text = preg_replace( '/<noinclude>.*?<\/noinclude>/s', '', $text ); |
— | — | @@ -2572,6 +2572,19 @@ |
2573 | 2573 | return $text; |
2574 | 2574 | } |
2575 | 2575 | } |
| 2576 | + |
| 2577 | + /** |
| 2578 | + * Trim the first and last newlines of a string, this is not equivalent |
| 2579 | + * to trim( $str, "\n" ) which would trim them all. |
| 2580 | + * |
| 2581 | + * @param string $str The string to trim |
| 2582 | + * @return string |
| 2583 | + */ |
| 2584 | + function trimOnlyinclude( $str ) { |
| 2585 | + $str = preg_replace( "/^\n/", '', $str ); |
| 2586 | + $str = preg_replace( "/\n$/", '', $str ); |
| 2587 | + return $str; |
| 2588 | + } |
2576 | 2589 | |
2577 | 2590 | /** |
2578 | 2591 | * Translude an interwiki link. |