2011-04-09 00:39:40 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* MediaWiki math extension
|
|
|
|
*
|
2011-04-09 15:13:22 +00:00
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
2014-07-12 22:16:20 +00:00
|
|
|
* @version 2.0
|
2011-04-09 15:13:22 +00:00
|
|
|
* @author Tomasz Wegrzanowski
|
|
|
|
* @author Brion Vibber
|
2012-10-27 14:30:50 +00:00
|
|
|
* @author Moritz Schubotz
|
2014-07-14 16:14:25 +00:00
|
|
|
* @author Derk-Jan Hartman
|
2012-03-05 22:25:09 +00:00
|
|
|
* @copyright © 2002-2012 various MediaWiki contributors
|
2011-04-09 15:13:22 +00:00
|
|
|
* @license GPLv2 license; info in main package.
|
|
|
|
* @link http://www.mediawiki.org/wiki/Extension:Math Documentation
|
|
|
|
* @see https://bugzilla.wikimedia.org/show_bug.cgi?id=14202
|
2011-04-09 00:39:40 +00:00
|
|
|
*/
|
|
|
|
|
2011-04-09 15:13:22 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
|
|
|
die( "This is not a valid entry point to MediaWiki.\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extension credits that will show up on Special:Version
|
|
|
|
$wgExtensionCredits['parserhook'][] = array(
|
2011-09-30 20:55:54 +00:00
|
|
|
'path' => __FILE__,
|
2011-04-09 15:13:22 +00:00
|
|
|
'name' => 'Math',
|
2014-07-12 22:16:20 +00:00
|
|
|
'version' => '2.0.0',
|
2014-07-14 16:14:25 +00:00
|
|
|
'author' => array(
|
|
|
|
'Tomasz Wegrzanowski',
|
|
|
|
'Brion Vibber',
|
|
|
|
'Moritz Schubotz',
|
|
|
|
'Derk-Jan Hartman',
|
|
|
|
),
|
2012-01-22 23:00:21 +00:00
|
|
|
'descriptionmsg' => 'math-desc',
|
2011-12-13 23:49:33 +00:00
|
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:Math',
|
2011-04-09 15:13:22 +00:00
|
|
|
);
|
|
|
|
|
2011-04-09 19:57:35 +00:00
|
|
|
/**@{
|
|
|
|
* Maths constants
|
|
|
|
*/
|
|
|
|
define( 'MW_MATH_PNG', 0 );
|
2011-11-28 22:30:33 +00:00
|
|
|
define( 'MW_MATH_SIMPLE', 1 ); /// @deprecated
|
|
|
|
define( 'MW_MATH_HTML', 2 ); /// @deprecated
|
2011-04-09 19:57:35 +00:00
|
|
|
define( 'MW_MATH_SOURCE', 3 );
|
2011-11-28 22:30:33 +00:00
|
|
|
define( 'MW_MATH_MODERN', 4 ); /// @deprecated
|
2014-06-10 16:49:20 +00:00
|
|
|
define( 'MW_MATH_MATHML', 5 );
|
2014-04-08 13:57:15 +00:00
|
|
|
define( 'MW_MATH_MATHJAX', 6 ); /// @deprecated
|
2013-05-14 21:49:06 +00:00
|
|
|
define( 'MW_MATH_LATEXML', 7 ); /// new in 1.22
|
2014-10-09 00:37:28 +00:00
|
|
|
define( 'MW_MATH_LATEXML_JAX', 8 ); /// new in 1.22
|
2011-04-09 19:57:35 +00:00
|
|
|
/**@}*/
|
|
|
|
|
2014-03-17 06:14:02 +00:00
|
|
|
/**@{
|
|
|
|
* Mathstyle constants
|
|
|
|
*/
|
|
|
|
define( 'MW_MATHSTYLE_INLINE_DISPLAYSTYLE', 0 ); //default large operator inline
|
|
|
|
define( 'MW_MATHSTYLE_DISPLAY', 1 ); // large operators centered in a new line
|
|
|
|
define( 'MW_MATHSTYLE_INLINE', 2 ); // small operators inline
|
|
|
|
// There is no style which renders small operators
|
|
|
|
// but display the equation centered in a new line.
|
|
|
|
/**@}*/
|
|
|
|
|
2014-04-08 13:57:15 +00:00
|
|
|
/**@var array defines the mode allowed on the server */
|
2015-05-20 10:35:42 +00:00
|
|
|
$wgMathValidModes = array( MW_MATH_PNG, MW_MATH_SOURCE, MW_MATH_MATHML );
|
2014-04-08 13:57:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The default rendering mode for anonymous users.
|
|
|
|
* Valid options are defined in $wgMathValidModes.
|
|
|
|
*/
|
|
|
|
$wgDefaultUserOptions['math'] = MW_MATH_PNG;
|
|
|
|
|
2011-04-09 00:39:40 +00:00
|
|
|
/** Location of the texvc binary */
|
2014-03-28 09:48:15 +00:00
|
|
|
$wgTexvc = __DIR__ . '/math/texvc';
|
2011-04-09 00:39:40 +00:00
|
|
|
/**
|
2011-04-09 15:13:22 +00:00
|
|
|
* Texvc background color
|
|
|
|
* use LaTeX color format as used in \special function
|
|
|
|
* for transparent background use value 'Transparent' for alpha transparency or
|
|
|
|
* 'transparent' for binary transparency.
|
|
|
|
*/
|
2011-04-09 00:39:40 +00:00
|
|
|
$wgTexvcBackgroundColor = 'transparent';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Normally when generating math images, we double-check that the
|
|
|
|
* directories we want to write to exist, and that files that have
|
|
|
|
* been generated still exist when we need to bring them up again.
|
|
|
|
*
|
|
|
|
* This lets us give useful error messages in case of permission
|
|
|
|
* problems, and automatically rebuild images that have been lost.
|
|
|
|
*
|
|
|
|
* On a big site with heavy NFS traffic this can be slow and flaky,
|
|
|
|
* so sometimes we want to short-circuit it by setting this to false.
|
|
|
|
*/
|
|
|
|
$wgMathCheckFiles = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The URL path of the math directory. Defaults to "{$wgUploadPath}/math".
|
|
|
|
*
|
|
|
|
* See http://www.mediawiki.org/wiki/Manual:Enable_TeX for details about how to
|
|
|
|
* set up mathematical formula display.
|
|
|
|
*/
|
2011-04-09 15:13:22 +00:00
|
|
|
$wgMathPath = false;
|
2011-04-09 00:39:40 +00:00
|
|
|
|
2012-08-20 22:11:16 +00:00
|
|
|
/**
|
|
|
|
* The name of a file backend ($wgFileBackends) to use for storing math renderings.
|
|
|
|
* Defaults to FSFileBackend using $wgMathDirectory as a base path.
|
|
|
|
*
|
|
|
|
* See http://www.mediawiki.org/wiki/Manual:Enable_TeX for details about how to
|
|
|
|
* set up mathematical formula display.
|
|
|
|
*/
|
|
|
|
$wgMathFileBackend = false;
|
|
|
|
|
2011-04-09 00:39:40 +00:00
|
|
|
/**
|
|
|
|
* The filesystem path of the math directory.
|
|
|
|
* Defaults to "{$wgUploadDirectory}/math".
|
|
|
|
*
|
|
|
|
* See http://www.mediawiki.org/wiki/Manual:Enable_TeX for details about how to
|
|
|
|
* set up mathematical formula display.
|
|
|
|
*/
|
2011-04-09 15:13:22 +00:00
|
|
|
$wgMathDirectory = false;
|
2011-04-09 00:39:40 +00:00
|
|
|
|
2014-06-05 09:31:28 +00:00
|
|
|
/**
|
|
|
|
* The url of the mathoid server.
|
2015-01-22 18:56:13 +00:00
|
|
|
*
|
|
|
|
* Documentation: http://www.formulasearchengine.com/mathoid
|
|
|
|
* Example value: http://mathoid.example.org:10042
|
|
|
|
*
|
|
|
|
* @todo Move documentation to mediawiki.org
|
2014-06-05 09:31:28 +00:00
|
|
|
*/
|
2014-06-10 16:49:20 +00:00
|
|
|
$wgMathMathMLUrl = 'http://mathoid.testme.wmflabs.org';
|
2014-06-05 09:31:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The timeout for the HTTP-Request sent to the MathML to render an equation,
|
|
|
|
* in seconds.
|
|
|
|
*/
|
|
|
|
$wgMathMathMLTimeout = 20;
|
|
|
|
|
2013-05-14 21:49:06 +00:00
|
|
|
/**
|
|
|
|
* Use of LaTeXML for details see
|
|
|
|
* <http://latexml.mathweb.org/help>
|
|
|
|
*
|
|
|
|
* If you want or need to run your own server, follow these installation
|
2014-01-26 00:43:41 +00:00
|
|
|
* instructions and override $wgMathLaTeXMLUrl:
|
|
|
|
* <http://www.formulasearchengine.com/LaTeXML>
|
2013-05-14 21:49:06 +00:00
|
|
|
*
|
|
|
|
* If you expect heavy load you can specify multiple servers. In that case one
|
|
|
|
* server is randomly chosen for each rendering process. Specify the list of
|
2014-01-26 00:43:41 +00:00
|
|
|
* servers in an array e.g $wgMathLaTeXMLUrl = array ( 'http://latexml.example.com/convert',
|
2013-05-14 21:49:06 +00:00
|
|
|
* 'http://latexml2.example.com/convert');
|
|
|
|
*/
|
2014-05-05 16:13:43 +00:00
|
|
|
$wgMathLaTeXMLUrl = 'http://gw125.iu.xsede.org:8888'; // Sponsored by https://www.xsede.org/
|
2013-05-14 21:49:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The timeout for the HTTP-Request sent to the LaTeXML to render an equation,
|
|
|
|
* in seconds.
|
|
|
|
*/
|
2014-01-26 00:43:41 +00:00
|
|
|
$wgMathLaTeXMLTimeout = 240;
|
2013-07-25 07:14:30 +00:00
|
|
|
/**
|
|
|
|
* Setting for the LaTeXML renderer.
|
|
|
|
* See http://dlmf.nist.gov/LaTeXML/manual/commands/latexmlpost.xhtml for details.
|
|
|
|
*/
|
2014-04-08 10:39:12 +00:00
|
|
|
$wgMathDefaultLaTeXMLSetting = array(
|
|
|
|
'format' => 'xhtml',
|
|
|
|
'whatsin' => 'math',
|
|
|
|
'whatsout' => 'math',
|
|
|
|
'pmml',
|
|
|
|
'cmml',
|
2015-05-28 12:26:56 +00:00
|
|
|
'mathtex',
|
2014-04-08 10:39:12 +00:00
|
|
|
'nodefaultresources',
|
|
|
|
'preload' => array( 'LaTeX.pool',
|
|
|
|
'article.cls',
|
|
|
|
'amsmath.sty',
|
|
|
|
'amsthm.sty',
|
|
|
|
'amstext.sty',
|
|
|
|
'amssymb.sty',
|
|
|
|
'eucal.sty',
|
|
|
|
'[dvipsnames]xcolor.sty',
|
|
|
|
'url.sty',
|
|
|
|
'hyperref.sty',
|
|
|
|
'[ids]latexml.sty',
|
|
|
|
'texvc' ),
|
|
|
|
);
|
2014-01-03 14:29:03 +00:00
|
|
|
/**
|
2014-02-10 21:48:55 +00:00
|
|
|
* The link to the texvccheck executable
|
2014-01-03 14:29:03 +00:00
|
|
|
*/
|
2014-03-28 09:48:15 +00:00
|
|
|
$wgMathTexvcCheckExecutable = __DIR__ . '/texvccheck/texvccheck';
|
2014-09-06 01:59:13 +00:00
|
|
|
|
|
|
|
/**@{
|
|
|
|
* Math check constants
|
2014-01-03 14:29:03 +00:00
|
|
|
*/
|
2014-09-06 01:59:13 +00:00
|
|
|
define( 'MW_MATH_CHECK_ALWAYS', 0 ); /// backwards compatible to false
|
|
|
|
define( 'MW_MATH_CHECK_NEVER' , 1 ); /// backwards compatible to true
|
|
|
|
define( 'MW_MATH_CHECK_NEW' , 2 );
|
|
|
|
/**@}*/
|
|
|
|
/**
|
|
|
|
* Option to disable the TeX security filter:
|
|
|
|
* In general every math object, which is rendered by the math extension has its rendering cached in
|
|
|
|
* a database.
|
|
|
|
* MW_MATH_CHECK_ALWAYS: If set to MW_MATH_CHECK_ALWAYS only a subset of the TeX commands is allowed.
|
|
|
|
* See the Wikipedia page Help:Math for details about the allowed commands.
|
|
|
|
* MW_MATH_CHECK_NONE: If set to MW_MATH_CHECK_NONE any TeX expression is parsed.
|
|
|
|
* This can be a potential security risk.
|
|
|
|
* MW_MATH_CHECK_NEW checks only new equations. If the database does not yet contain the given math object,
|
|
|
|
* then it is passed through texvccheck.
|
|
|
|
* Please make sure to truncate the database tables (math, mathoid, mathlatexml) when switching from
|
|
|
|
* MW_MATH_CHECK_NONE to MW_MATH_CHECK_NEW. Otherwise, unchecked content contained in the database
|
|
|
|
* will be displayed.
|
|
|
|
*/
|
|
|
|
$wgMathDisableTexFilter = MW_MATH_CHECK_NEW;
|
2014-06-05 09:31:28 +00:00
|
|
|
|
2014-06-10 11:18:26 +00:00
|
|
|
/** @var boolean $wgMathEnableExperimentalInputFormats enables experimental MathML and AsciiMath input format support */
|
|
|
|
$wgMathEnableExperimentalInputFormats = false;
|
2011-04-09 00:39:40 +00:00
|
|
|
////////// end of config settings.
|
|
|
|
|
|
|
|
$wgExtensionFunctions[] = 'MathHooks::setup';
|
|
|
|
$wgHooks['ParserFirstCallInit'][] = 'MathHooks::onParserFirstCallInit';
|
|
|
|
$wgHooks['GetPreferences'][] = 'MathHooks::onGetPreferences';
|
2011-04-22 21:37:16 +00:00
|
|
|
$wgHooks['LoadExtensionSchemaUpdates'][] = 'MathHooks::onLoadExtensionSchemaUpdates';
|
|
|
|
$wgHooks['ParserTestTables'][] = 'MathHooks::onParserTestTables';
|
2013-02-16 22:55:39 +00:00
|
|
|
$wgHooks['UnitTestsList'][] = 'MathHooks::onRegisterUnitTests';
|
2014-01-02 17:18:51 +00:00
|
|
|
$wgHooks['PageRenderingHash'][] = 'MathHooks::onPageRenderingHash';
|
2014-01-25 23:09:06 +00:00
|
|
|
$wgHooks['EditPageBeforeEditToolbar'][] = 'MathHooks::onEditPageBeforeEditToolbar';
|
2011-04-09 00:39:40 +00:00
|
|
|
|
2014-03-28 09:48:15 +00:00
|
|
|
$dir = __DIR__ . '/';
|
2011-04-09 15:13:22 +00:00
|
|
|
$wgAutoloadClasses['MathHooks'] = $dir . 'Math.hooks.php';
|
2013-01-01 16:16:35 +00:00
|
|
|
$wgAutoloadClasses['MathRenderer'] = $dir . 'MathRenderer.php';
|
2012-10-27 14:30:50 +00:00
|
|
|
$wgAutoloadClasses['MathTexvc'] = $dir . 'MathTexvc.php';
|
|
|
|
$wgAutoloadClasses['MathSource'] = $dir . 'MathSource.php';
|
2014-06-03 08:15:53 +00:00
|
|
|
$wgAutoloadClasses['MathMathML'] = $dir . 'MathMathML.php';
|
2013-05-14 21:49:06 +00:00
|
|
|
$wgAutoloadClasses['MathLaTeXML'] = $dir . 'MathLaTeXML.php';
|
2014-01-03 14:29:03 +00:00
|
|
|
$wgAutoloadClasses['MathInputCheck'] = $dir . 'MathInputCheck.php';
|
|
|
|
$wgAutoloadClasses['MathInputCheckTexvc'] = $dir . 'MathInputCheckTexvc.php';
|
2014-06-05 22:12:33 +00:00
|
|
|
$wgAutoloadClasses['SpecialMathShowImage'] = $dir . 'SpecialMathShowImage.php';
|
2015-01-24 08:25:04 +00:00
|
|
|
$wgAutoloadClasses['SpecialMathStatus'] = $dir . 'SpecialMathStatus.php';
|
2014-03-28 09:48:15 +00:00
|
|
|
$wgMessagesDirs['Math'] = __DIR__ . '/i18n';
|
2014-06-05 22:12:33 +00:00
|
|
|
$wgExtensionMessagesFiles['MathAlias'] = $dir . 'Math.alias.php';
|
2015-01-24 08:25:04 +00:00
|
|
|
$wgExtensionMessagesFiles['MathAliasNoTranslate'] = $dir . 'Math.alias.noTranslate.php';
|
2011-04-09 00:39:40 +00:00
|
|
|
|
2011-09-30 20:55:54 +00:00
|
|
|
$wgParserTestFiles[] = $dir . 'mathParserTests.txt';
|
2011-12-06 01:17:35 +00:00
|
|
|
|
2014-06-05 22:12:33 +00:00
|
|
|
$wgSpecialPages['MathShowImage'] = 'SpecialMathShowImage';
|
2015-01-24 08:25:04 +00:00
|
|
|
$wgSpecialPages['MathStatus'] = 'SpecialMathStatus';
|
2011-12-06 01:17:35 +00:00
|
|
|
|
2014-03-17 06:14:02 +00:00
|
|
|
$wgResourceModules['ext.math.styles'] = array(
|
2015-04-28 14:03:20 +00:00
|
|
|
'position' => 'top',
|
2014-03-17 06:14:02 +00:00
|
|
|
'localBasePath' => __DIR__ . '/modules',
|
|
|
|
'remoteExtPath' => 'Math/modules',
|
|
|
|
'styles' => 'ext.math.css',
|
2014-10-20 20:40:53 +00:00
|
|
|
'targets' => array( 'desktop', 'mobile' ),
|
|
|
|
);
|
|
|
|
$wgResourceModules['ext.math.desktop.styles'] = array(
|
2015-04-28 14:03:20 +00:00
|
|
|
'position' => 'top',
|
2014-10-20 20:40:53 +00:00
|
|
|
'localBasePath' => __DIR__ . '/modules',
|
|
|
|
'remoteExtPath' => 'Math/modules',
|
|
|
|
'styles' => 'ext.math.desktop.css',
|
2014-03-17 06:14:02 +00:00
|
|
|
);
|
2014-10-10 10:38:23 +00:00
|
|
|
$wgResourceModules['ext.math.scripts'] = array(
|
|
|
|
'localBasePath' => __DIR__ . '/modules',
|
|
|
|
'remoteExtPath' => 'Math/modules',
|
|
|
|
'scripts' => 'ext.math.js',
|
|
|
|
);
|
2014-03-17 06:14:02 +00:00
|
|
|
|
2014-01-06 09:07:24 +00:00
|
|
|
|
|
|
|
$moduleTemplate = array(
|
2014-03-28 09:48:15 +00:00
|
|
|
'localBasePath' => __DIR__ . '/modules',
|
2014-01-06 09:07:24 +00:00
|
|
|
'remoteExtPath' => 'Math/modules',
|
|
|
|
);
|
|
|
|
|
2014-01-25 23:09:06 +00:00
|
|
|
$wgResourceModules['ext.math.editbutton.enabler'] = array(
|
|
|
|
'scripts' => 'ext.math.editbutton.js',
|
|
|
|
'messages' => array(
|
|
|
|
'math_tip',
|
|
|
|
'math_sample',
|
|
|
|
),
|
|
|
|
) + $moduleTemplate;
|
|
|
|
|
2014-01-06 09:07:24 +00:00
|
|
|
$wgResourceModules['ext.math.visualEditor'] = array(
|
|
|
|
'scripts' => array(
|
|
|
|
'VisualEditor/ve.dm.MWMathNode.js',
|
|
|
|
'VisualEditor/ve.ce.MWMathNode.js',
|
|
|
|
'VisualEditor/ve.ui.MWMathInspector.js',
|
|
|
|
'VisualEditor/ve.ui.MWMathInspectorTool.js',
|
|
|
|
),
|
2014-06-19 11:37:33 +00:00
|
|
|
'styles' => array(
|
2014-11-12 18:46:46 +00:00
|
|
|
'VisualEditor/ve.ce.MWMathNode.css',
|
2014-06-19 11:37:33 +00:00
|
|
|
'VisualEditor/ve.ui.MWMathIcons.css',
|
2015-01-16 12:07:14 +00:00
|
|
|
'VisualEditor/ve.ui.MWMathInspector.css',
|
2014-06-19 11:37:33 +00:00
|
|
|
),
|
2014-01-06 09:07:24 +00:00
|
|
|
'dependencies' => array(
|
|
|
|
'ext.visualEditor.mwcore',
|
|
|
|
),
|
|
|
|
'messages' => array(
|
2014-11-12 15:28:57 +00:00
|
|
|
'math-visualeditor-mwmathinspector-display',
|
|
|
|
'math-visualeditor-mwmathinspector-display-block',
|
|
|
|
'math-visualeditor-mwmathinspector-display-default',
|
|
|
|
'math-visualeditor-mwmathinspector-display-inline',
|
|
|
|
'math-visualeditor-mwmathinspector-id',
|
2014-01-06 09:07:24 +00:00
|
|
|
'math-visualeditor-mwmathinspector-title',
|
|
|
|
),
|
|
|
|
'targets' => array( 'desktop', 'mobile' ),
|
|
|
|
) + $moduleTemplate;
|
|
|
|
|
2014-04-29 20:34:40 +00:00
|
|
|
$wgVisualEditorPluginModules[] = 'ext.math.visualEditor';
|