3 * Tag hooks provided by MediaWiki core
9 * Various tag hooks, registered in Parser::firstCallInit()
13 static function register( $parser ) {
14 global $wgRawHtml, $wgUseTeX;
15 $parser->setHook( 'pre', array( __CLASS__
, 'pre' ) );
16 $parser->setHook( 'nowiki', array( __CLASS__
, 'nowiki' ) );
17 $parser->setHook( 'gallery', array( __CLASS__
, 'gallery' ) );
19 $parser->setHook( 'html', array( __CLASS__
, 'html' ) );
22 $parser->setHook( 'math', array( __CLASS__
, 'math' ) );
26 static function pre( $text, $attribs, $parser ) {
27 // Backwards-compatibility hack
28 $content = StringUtils
::delimiterReplace( '<nowiki>', '</nowiki>', '$1', $text, 'i' );
30 $attribs = Sanitizer
::validateTagAttributes( $attribs, 'pre' );
31 return Xml
::openElement( 'pre', $attribs ) .
32 Xml
::escapeTagsOnly( $content ) .
36 static function html( $content, $attributes, $parser ) {
39 return array( $content, 'markerType' => 'nowiki' );
41 throw new MWException( '<html> extension tag encountered unexpectedly' );
45 static function nowiki( $content, $attributes, $parser ) {
46 $content = strtr( $content, array( '-{' => '-{', '}-' => '}-' ) );
47 return array( Xml
::escapeTagsOnly( $content ), 'markerType' => 'nowiki' );
50 static function math( $content, $attributes, $parser ) {
52 return $wgContLang->armourMath( MathRenderer
::renderMath( $content, $attributes, $parser->getOptions() ) );
55 static function gallery( $content, $attributes, $parser ) {
56 return $parser->renderImageGallery( $content, $attributes );