diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2010-07-28 11:52:48 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2010-07-28 11:52:48 +0200 |
commit | 222b01f5169f1c7e69762e0e8904c24f78f71882 (patch) | |
tree | 8e932e12546bb991357ec48eb1638d1770be7a35 /includes/parser/CoreTagHooks.php | |
parent | 00ab76a6b686e98a914afc1975812d2b1aaa7016 (diff) |
update to MediaWiki 1.16.0
Diffstat (limited to 'includes/parser/CoreTagHooks.php')
-rw-r--r-- | includes/parser/CoreTagHooks.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/includes/parser/CoreTagHooks.php b/includes/parser/CoreTagHooks.php new file mode 100644 index 00000000..7cc8260e --- /dev/null +++ b/includes/parser/CoreTagHooks.php @@ -0,0 +1,49 @@ +<?php + +class CoreTagHooks { + static function register( $parser ) { + global $wgRawHtml, $wgUseTeX; + $parser->setHook( 'pre', array( __CLASS__, 'pre' ) ); + $parser->setHook( 'nowiki', array( __CLASS__, 'nowiki' ) ); + $parser->setHook( 'gallery', array( __CLASS__, 'gallery' ) ); + if ( $wgRawHtml ) { + $parser->setHook( 'html', array( __CLASS__, 'html' ) ); + } + if ( $wgUseTeX ) { + $parser->setHook( 'math', array( __CLASS__, 'math' ) ); + } + } + + static function pre( $text, $attribs, $parser ) { + // Backwards-compatibility hack + $content = StringUtils::delimiterReplace( '<nowiki>', '</nowiki>', '$1', $text, 'i' ); + + $attribs = Sanitizer::validateTagAttributes( $attribs, 'pre' ); + return Xml::openElement( 'pre', $attribs ) . + Xml::escapeTagsOnly( $content ) . + '</pre>'; + } + + static function html( $content, $attributes, $parser ) { + global $wgRawHtml; + if( $wgRawHtml ) { + return array( $content, 'markerType' => 'nowiki' ); + } else { + throw new MWException( '<html> extension tag encountered unexpectedly' ); + } + } + + static function nowiki( $content, $attributes, $parser ) { + $content = strtr( $content, array( '-{' => '-{', '}-' => '}-' ) ); + return array( Xml::escapeTagsOnly( $content ), 'markerType' => 'nowiki' ); + } + + static function math( $content, $attributes, $parser ) { + global $wgContLang; + return $wgContLang->armourMath( MathRenderer::renderMath( $content, $attributes ) ); + } + + static function gallery( $content, $attributes, $parser ) { + return $parser->renderImageGallery( $content, $attributes ); + } +} |