1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 );
}
}
|