Extension:ASCIIMath4Wiki
From MediaWiki.org
|
ASCIIMath4Wiki Release status: stable |
|
|---|---|
| Implementation | Tag |
| Description | Adds a tag that outputs math expressions in ASCIIMath as MathML. |
| Author(s) | Ariston Martins Cordeiro |
| Version | 1.0 (2006-06-12) |
| MediaWiki | 1.6+ |
| Download | sspecter.mhx6.com |
This extension adds a <asciimath> tag that outputs math expressions written in ASCIIMathML as MathML.
It is a lighter alternative to LaTeX for mathematical expressions, which has higher demands in terms of storage space, process, Linux package installations, et cetera. This extension doesn't create image files, nor require any 3rd party server-side packages, but rely on client's browser support for rendering MathML. ASCIIMathML's syntax is also easier and more human-legible than LaTeX's.
Contents |
[edit] Usage
[edit] Syntax
Math expressions can be written in ASCIIMathML syntax, contained by the custom <asciimath> tag:
<asciimath>ASCIIMath_expressions</asciimath>
[edit] Browser compatibility
MathML is a World Wide Web Consortium standard, but not all browsers support it properly.
- Firefox supports MathML, but requires a separate font to show it properly; see the font's installation guide.
- Internet Explorer doesn't support MathML at all; Internet Explorer users can view MathML with the Math Player plugin.
[edit] Installation
The extension requires MediaWiki 1.6+ and the ASCIIMathPHP 1.1+ PHP extension (PHP extension included in the file), and the skin files must be modified to support MathML. Also, avoid using this extension with TeX; If you're using TeX, try to use that for math instead.
- Download the extension (includes ASCIIMath4Wiki and ASCIIMathPHP).
- Unpack the files to /extensions/ in the root of your MediaWiki installation. The package should include ASCIIMath4Wiki.php, ASCIIMathPHP.cfg.php, and ASCIIMathPHP.class.php.
- Add the following line to LocalSettings.php (near the bottom):
include("extensions/ASCIIMath4Wiki.php"); - Specify the skins as XML and change their DTDs to support XHTML+MathML (see below).
- Watch out for unclean HTML rendering in wiki extensions.
[edit] Changing DTD
Caution: All wiki HTML tags rendered (even the ones parsed from the wiki text) are XHTML compatible, so the MediaWiki alone won't have any problem outputting as XHTML. But watch out for unclean HTML in other wiki extensions. Keep in mind that any tag error in output will generate an XHTML parsing error, "breaking" the page; XHTML is very unforgiving.
MediaWiki skins render pages as HTML. To allow MathML in your skin, you must make it as XHTML+MathML (by rendering it as a XML document and specifying the header about the XHTML and MathML tags). That mean you will have to change the wiki's page rendering to all allowed skins.
Below is an example of how to change MonoBook:
Open /skins/MonoBook.php in your wiki and find these lines; make sure to make the equivalent change in each skin's main file.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
Change the above to this:
<?php header('Content-type: application/xhtml+xml; ;charset=utf-8');
header('Vary: Accept');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [
<!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
]>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
Remember you should change it in all allowed skins, not only Monobook.

