$content = StringUtils::delimiterReplace( '<nowiki>', '</nowiki>', '$1', $text, 'i' );
$attribs = Sanitizer::validateTagAttributes( $attribs, 'pre' );
- return Xml::openElement( 'pre', $attribs ) .
- Xml::escapeTagsOnly( $content ) .
- '</pre>';
+ // We need to let both '"' and '&' through,
+ // for strip markers and entities respectively.
+ $content = str_replace(
+ [ '>', '<' ],
+ [ '>', '<' ],
+ $content
+ );
+ return Html::rawElement( 'pre', $attribs, $content );
}
/**
* @return array
*/
public static function nowiki( $content, $attributes, $parser ) {
- $content = strtr( $content, [ '-{' => '-{', '}-' => '}-' ] );
- return [ Xml::escapeTagsOnly( $content ), 'markerType' => 'nowiki' ];
+ $content = strtr( $content, [
+ // lang converter
+ '-{' => '-{',
+ '}-' => '}-',
+ // html tags
+ '<' => '<',
+ '>' => '>'
+ // Note: Both '"' and '&' are not converted.
+ // This allows strip markers and entities through.
+ ] );
+ return [ $content, 'markerType' => 'nowiki' ];
}
/**