# Maybe transform using the full parser
if ( $this->format === 'parse' ) {
$string = $this->parseText( $string );
- $m = array();
- if ( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
- $string = $m[1];
- }
+ $string = Parser::stripOuterParagraph( $string );
} elseif ( $this->format === 'block-parse' ) {
$string = $this->parseText( $string );
} elseif ( $this->format === 'text' ) {
* @return string Wikitext parsed into HTML.
*/
protected function parseText( $string ) {
- $out = MessageCache::singleton()->parse( $string, $this->title, /*linestart*/true, $this->interface, $this->language );
+ $out = MessageCache::singleton()->parse(
+ $string,
+ $this->title,
+ /*linestart*/true,
+ $this->interface,
+ $this->language
+ );
+
return $out instanceof ParserOutput ? $out->getText() : $out;
}
* @return string Wikitext with {{-constructs replaced with their values.
*/
protected function transformText( $string ) {
- return MessageCache::singleton()->transform( $string, $this->interface, $this->language, $this->title );
+ return MessageCache::singleton()->transform(
+ $string,
+ $this->interface,
+ $this->language,
+ $this->title
+ );
}
/**