* (bug 7774) MATH: aded more amstex functions
* (bug 1182) MATH: fixed inconsistent rendering of upper case Greek letters in TeX
* Fix regression in streaming page dump generation
+* (bug 7801) Add support for parser function hooks in parser tests
== Languages updated ==
}
$this->hooks = array();
+ $this->functionHooks = array();
}
/**
$section = null;
continue;
}
+ if( $section == 'endfunctionhooks' ) {
+ if( !isset( $data['functionhooks'] ) ) {
+ wfDie( "'endfunctionhooks' without 'functionhooks' at line $n\n" );
+ }
+ foreach( explode( "\n", $data['functionhooks'] ) as $line ) {
+ $line = trim( $line );
+ if( $line ) {
+ $this->requireFunctionHook( $line );
+ }
+ }
+ $data = array();
+ $section = null;
+ continue;
+ }
if( $section == 'end' ) {
if( !isset( $data['test'] ) ) {
wfDie( "'end' without 'test' at line $n\n" );
foreach( $this->hooks as $tag => $callback ) {
$parser->setHook( $tag, $callback );
}
+ foreach( $this->functionHooks as $tag => $callback ) {
+ $parser->setFunctionHook( $tag, $callback );
+ }
wfRunHooks( 'ParserTestParser', array( &$parser ) );
$title =& Title::makeTitle( NS_MAIN, $titleText );
}
}
+
+ /**
+ * Steal a callback function from the primary parser, save it for
+ * application to our scary parser. If the hook is not installed,
+ * die a painful dead to warn the others.
+ * @param string $name
+ */
+ private function requireFunctionHook( $name ) {
+ global $wgParser;
+ if( isset( $wgParser->mFunctionHooks[$name] ) ) {
+ $this->functionHooks[$name] = $wgParser->mFunctionHooks[$name];
+ } else {
+ wfDie( "This test suite requires the '$name' function hook extension.\n" );
+ }
+ }
+
/*
* Run the "tidy" command on text if the $wgUseTidy
* global is true