3 * Tag hooks provided by MediaWiki core
9 * Various tag hooks, registered in Parser::firstCallInit()
15 * @param $parser Parser
18 static function register( $parser ) {
19 global $wgRawHtml, $wgUseTeX;
20 $parser->setHook( 'pre', array( __CLASS__
, 'pre' ) );
21 $parser->setHook( 'nowiki', array( __CLASS__
, 'nowiki' ) );
22 $parser->setHook( 'gallery', array( __CLASS__
, 'gallery' ) );
24 $parser->setHook( 'html', array( __CLASS__
, 'html' ) );
27 $parser->setHook( 'math', array( __CLASS__
, 'math' ) );
31 static function pre( $text, $attribs, $parser ) {
32 // Backwards-compatibility hack
33 $content = StringUtils
::delimiterReplace( '<nowiki>', '</nowiki>', '$1', $text, 'i' );
35 $attribs = Sanitizer
::validateTagAttributes( $attribs, 'pre' );
36 return Xml
::openElement( 'pre', $attribs ) .
37 Xml
::escapeTagsOnly( $content ) .
41 static function html( $content, $attributes, $parser ) {
44 return array( $content, 'markerType' => 'nowiki' );
46 throw new MWException( '<html> extension tag encountered unexpectedly' );
50 static function nowiki( $content, $attributes, $parser ) {
51 $content = strtr( $content, array( '-{' => '-{', '}-' => '}-' ) );
52 return array( Xml
::escapeTagsOnly( $content ), 'markerType' => 'nowiki' );
59 * @param $parser Parser
62 static function math( $content, $attributes, $parser ) {
64 return $wgContLang->armourMath( MathRenderer
::renderMath( $content, $attributes, $parser->getOptions() ) );
71 * @param $parser Parser
74 static function gallery( $content, $attributes, $parser ) {
75 return $parser->renderImageGallery( $content, $attributes );