Index: trunk/phase3/includes/Parser.php |
— | — | @@ -2777,7 +2777,7 @@ |
2778 | 2778 | $i = strlen( $text ); |
2779 | 2779 | } else { |
2780 | 2780 | // Search backwards for leading whitespace |
2781 | | - $wsStart = $i ? ( $i - strspn( $revText, ' ', strlen( $text ) - $i - 1 ) ) : 0; |
| 2781 | + $wsStart = $i ? ( $i - strspn( $revText, ' ', strlen( $text ) - $i ) ) : 0; |
2782 | 2782 | // Search forwards for trailing whitespace |
2783 | 2783 | // $wsEnd will be the position of the last space |
2784 | 2784 | $wsEnd = $endPos + 2 + strspn( $text, ' ', $endPos + 3 ); |
— | — | @@ -2787,11 +2787,18 @@ |
2788 | 2788 | { |
2789 | 2789 | $startPos = $wsStart; |
2790 | 2790 | $endPos = $wsEnd + 1; |
| 2791 | + // Remove leading whitespace from the end of the accumulator |
| 2792 | + // Sanity check first though |
| 2793 | + $wsLength = $i - $wsStart; |
| 2794 | + if ( $wsLength > 0 && substr( $accum, -$wsLength ) === str_repeat( ' ', $wsLength ) ) { |
| 2795 | + $accum = substr( $accum, 0, -$wsLength ); |
| 2796 | + } |
2791 | 2797 | } else { |
2792 | 2798 | // No line to eat, just take the comment itself |
2793 | 2799 | $startPos = $i; |
2794 | 2800 | $endPos += 2; |
2795 | 2801 | } |
| 2802 | + |
2796 | 2803 | $inner = substr( $text, $startPos, $endPos - $startPos + 1 ); |
2797 | 2804 | $accum .= '<comment>' . htmlspecialchars( $inner ) . '</comment>'; |
2798 | 2805 | $i = $endPos + 1; |
— | — | @@ -5425,7 +5432,7 @@ |
5426 | 5433 | } elseif ( $root->nodeName == 'comment' ) { |
5427 | 5434 | # HTML-style comment |
5428 | 5435 | if ( $this->parser->ot['html'] |
5429 | | - || ( $this->parser->ot['pre'] && $this->mOptions->getRemoveComments() ) |
| 5436 | + || ( $this->parser->ot['pre'] && $this->parser->mOptions->getRemoveComments() ) |
5430 | 5437 | || ( $flags & self::STRIP_COMMENTS ) ) |
5431 | 5438 | { |
5432 | 5439 | $s = ''; |