Extension:DollarSign

Category:Extensions which host their code in-wiki Category:Unmaintained extensions#DollarSign Category:Extensions without an imageCategory:Extensions without a compatibility policyCategory:GPL licensed extensions
MediaWiki extensions manual
DollarSign
Release status: unmaintainedCategory:Unmaintained extensions
Implementation Tag Category:Tag extensions
Description Allows to recognize the LaTeX-style inline math mode with dollar signs.
Author(s) Sori Lee (Soritalk)
Latest version 1.0 (2008-10-18)
MediaWiki 1.5+Category:Extensions with manual MediaWiki version
Database changes No
License GNU General Public License 2.0 or later
Download See the code section
Category:All extensionsCategory:Extensions not in ExtensionJson

The DollarSign extension allows to recognize the LaTeX-style inline math mode with dollar signs. To print the dollar sign, type the dollar sign preceded by one backslash.

Installing

Code

DollarSign.php
<?php
/**
 * @author Sori Lee <sori24 (at) gmail (dot) com>
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 */

if(!defined('MEDIAWIKI'))
    die("This is an extension to the MediaWiki package and cannot be run standalone.");

// Register as an extention
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'DollarSign',
	'version' => '1.0',
	'url' => 'https://www.mediawiki.org/wiki/Extension:DollarSign',
	'author' => 'Sori Lee',
	'description' => 'Allows to recognize the LaTeX-style inline math mode with dollar signs',
);

// Register hooks
$wgHooks['ParserBeforeInternalParse'][] = 'dsParse';

// Parse function
function dsParse( &$parser, &$text, &$stripState ) {
	// We replace '$...$' by '<math>...</math>' and '\$' by '$'.
	$pattern = array('/([^\\\\]|^)\$([^\$]*)\$/', '/\\\\\$/');
	$replace = array('$1<math>$2</math>', '\$');

	// Perform the substitution.
	$text = preg_replace($pattern, $replace, $text);

	return true;
}
Category:Math display extensions
Category:All extensions Category:Extensions not in ExtensionJson Category:Extensions not using extension registration Category:Extensions which host their code in-wiki Category:Extensions with manual MediaWiki version Category:Extensions without a compatibility policy Category:Extensions without an image Category:GPL licensed extensions Category:Math display extensions Category:ParserBeforeInternalParse extensions Category:Tag extensions Category:Unmaintained extensions