Index: trunk/extensions/MobileFrontend/ApiQueryExcerpt.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | } |
34 | 34 | $text = $this->getExcerpt( $t, $params['plaintext'] ); |
35 | 35 | if ( isset( $params['length'] ) ) { |
36 | | - $text = $this->trimText( $text, $params['length'] ); |
| 36 | + $text = $this->trimText( $text, $params['length'], $params['plaintext'] ); |
37 | 37 | } |
38 | 38 | $fit = $this->addPageSubItem( $id, $text ); |
39 | 39 | if ( !$fit ) { |
— | — | @@ -114,7 +114,14 @@ |
115 | 115 | return trim( $text ); |
116 | 116 | } |
117 | 117 | |
118 | | - private function trimText( $text, $requestedLength ) { |
| 118 | + /** |
| 119 | + * |
| 120 | + * @param string $text |
| 121 | + * @param int $requestedLength |
| 122 | + * @param bool $plainText |
| 123 | + * @return string |
| 124 | + */ |
| 125 | + private function trimText( $text, $requestedLength, $plainText ) { |
119 | 126 | global $wgUseTidy; |
120 | 127 | |
121 | 128 | $length = mb_strlen( $text ); |
— | — | @@ -125,7 +132,7 @@ |
126 | 133 | preg_match( $pattern, $text, $m ); |
127 | 134 | $text = $m[0]; |
128 | 135 | // Fix possibly unclosed tags |
129 | | - if ( $wgUseTidy ) { |
| 136 | + if ( $wgUseTidy && !$plainText ) { |
130 | 137 | $text = trim ( MWTidy::tidy( $text ) ); |
131 | 138 | } |
132 | 139 | $text .= wfMessage( 'ellipsis' )->inContentLanguage()->text(); |