4 static function register( $parser ) {
5 global $wgRawHtml, $wgUseTeX;
6 $parser->setHook( 'pre', array( __CLASS__
, 'pre' ) );
7 $parser->setHook( 'nowiki', array( __CLASS__
, 'nowiki' ) );
8 $parser->setHook( 'gallery', array( __CLASS__
, 'gallery' ) );
10 $parser->setHook( 'html', array( __CLASS__
, 'html' ) );
13 $parser->setHook( 'math', array( __CLASS__
, 'math' ) );
17 static function pre( $text, $attribs, $parser ) {
18 // Backwards-compatibility hack
19 $content = StringUtils
::delimiterReplace( '<nowiki>', '</nowiki>', '$1', $text, 'i' );
21 $attribs = Sanitizer
::validateTagAttributes( $attribs, 'pre' );
22 return Xml
::openElement( 'pre', $attribs ) .
23 Xml
::escapeTagsOnly( $content ) .
27 static function html( $content, $attributes, $parser ) {
30 return array( $content, 'markerType' => 'nowiki' );
32 throw new MWException( '<html> extension tag encountered unexpectedly' );
36 static function nowiki( $content, $attributes, $parser ) {
37 $content = strtr( $content, array( '-{' => '-{', '}-' => '}-' ) );
38 return array( Xml
::escapeTagsOnly( $content ), 'markerType' => 'nowiki' );
41 static function math( $content, $attributes, $parser ) {
43 return $output = $wgContLang->armourMath( MathRenderer
::renderMath( $content, $attributes ) );
46 static function gallery( $content, $attributes, $parser ) {
47 return $parser->renderImageGallery( $content, $attributes );