Removed action=print; I can't find anything using this
[mediawiki.git] / includes / parser / CoreTagHooks.php
blob1d5208dc20a0c480a60f5074ce71a7f8eea52d0d
1 <?php
2 /**
3 * Tag hooks provided by MediaWiki core
5 * @file
6 */
8 /**
9 * Various tag hooks, registered in Parser::firstCallInit()
10 * @ingroup Parser
12 class CoreTagHooks {
13 /**
14 * @static
15 * @param $parser Parser
16 * @return void
18 static function register( $parser ) {
19 global $wgRawHtml;
20 $parser->setHook( 'pre', array( __CLASS__, 'pre' ) );
21 $parser->setHook( 'nowiki', array( __CLASS__, 'nowiki' ) );
22 $parser->setHook( 'gallery', array( __CLASS__, 'gallery' ) );
23 if ( $wgRawHtml ) {
24 $parser->setHook( 'html', array( __CLASS__, 'html' ) );
28 static function pre( $text, $attribs, $parser ) {
29 // Backwards-compatibility hack
30 $content = StringUtils::delimiterReplace( '<nowiki>', '</nowiki>', '$1', $text, 'i' );
32 $attribs = Sanitizer::validateTagAttributes( $attribs, 'pre' );
33 return Xml::openElement( 'pre', $attribs ) .
34 Xml::escapeTagsOnly( $content ) .
35 '</pre>';
38 static function html( $content, $attributes, $parser ) {
39 global $wgRawHtml;
40 if( $wgRawHtml ) {
41 return array( $content, 'markerType' => 'nowiki' );
42 } else {
43 throw new MWException( '<html> extension tag encountered unexpectedly' );
47 static function nowiki( $content, $attributes, $parser ) {
48 $content = strtr( $content, array( '-{' => '-&#123;', '}-' => '&#125;-' ) );
49 return array( Xml::escapeTagsOnly( $content ), 'markerType' => 'nowiki' );
52 /**
53 * @static
54 * @param $content
55 * @param $attributes
56 * @param $parser Parser
57 * @return
59 static function gallery( $content, $attributes, $parser ) {
60 return $parser->renderImageGallery( $content, $attributes );