From: Rob Church Date: Mon, 26 Jun 2006 15:50:03 +0000 (+0000) Subject: (bug 672) Add MathAfterTexvc hook X-Git-Tag: 1.31.0-rc.0~56589 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=048021c14add565a69ed64b5fda5c71b8c119c3d;p=lhc%2Fweb%2Fwiklou.git (bug 672) Add MathAfterTexvc hook --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 858f7c0b2c..c3f7266a6f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -570,6 +570,7 @@ Some default configuration options have changed: * Update to Esperanto translation (eo) * Check for preg_match() existence when installing and die out whining about PCRE if it's not there, instead of throwing a fatal error +* (bug 672) Add MathAfterTexvc hook == Compatibility == diff --git a/docs/hooks.txt b/docs/hooks.txt index 16db940d03..2e7db307d1 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -380,6 +380,11 @@ $user: user (object) who marked the edit patrolled $wcOnlySysopsCanPatrol: config setting indicating whether the user must be a sysop to patrol the edit +'MathAfterTexvc': after texvc is executed when rendering mathematics +$mathRenderer: instance of MathRenderer +$errmsg: error message, in HTML (string). Nonempty indicates failure + of rendering the formula + 'OutputPageBeforeHTML': a page has been processed by the parser and the resulting HTML is about to be displayed. $parserOutput: the parserOutput (object) that corresponds to the page diff --git a/includes/Math.php b/includes/Math.php index 1bf68b2bdd..f9d6a605b5 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -73,6 +73,7 @@ class MathRenderer { } $retval = substr ($contents, 0, 1); + $errmsg = ''; if (($retval == 'C') || ($retval == 'M') || ($retval == 'L')) { if ($retval == 'C') $this->conservativeness = 2; @@ -106,14 +107,23 @@ class MathRenderer { } else { $errbit = htmlspecialchars( substr($contents, 1) ); switch( $retval ) { - case 'E': return $this->_error( 'math_lexing_error', $errbit ); - case 'S': return $this->_error( 'math_syntax_error', $errbit ); - case 'F': return $this->_error( 'math_unknown_function', $errbit ); - default: return $this->_error( 'math_unknown_error', $errbit ); + case 'E': $errmsg = $this->_error( 'math_lexing_error', $errbit ); + case 'S': $errmsg = $this->_error( 'math_syntax_error', $errbit ); + case 'F': $errmsg = $this->_error( 'math_unknown_function', $errbit ); + default: $errmsg = $this->_error( 'math_unknown_error', $errbit ); } } - $this->hash = substr ($contents, 1, 32); + if ( !$errmsg ) { + $this->hash = substr ($contents, 1, 32); + } + + $res = wfRunHooks( 'MathAfterTexvc', array( &$this, &$errmsg ) ); + + if ( $errmsg ) { + return $errmsg; + } + if (!preg_match("/^[a-f0-9]{32}$/", $this->hash)) { return $this->_error( 'math_unknown_error' ); }