3 * Tag hooks provided by MediaWiki core
9 * Various tag hooks, registered in Parser::firstCallInit()
15 * @param $parser Parser
18 static function register( $parser ) {
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' ) );
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 ) .
38 static function html( $content, $attributes, $parser ) {
41 return array( $content, 'markerType' => 'nowiki' );
43 throw new MWException( '<html> extension tag encountered unexpectedly' );
47 static function nowiki( $content, $attributes, $parser ) {
48 $content = strtr( $content, array( '-{' => '-{', '}-' => '}-' ) );
49 return array( Xml
::escapeTagsOnly( $content ), 'markerType' => 'nowiki' );
56 * @param $parser Parser
59 static function gallery( $content, $attributes, $parser ) {
60 return $parser->renderImageGallery( $content, $attributes );