User:Tommy Ekola/Metapost

For version tested with 1.11.0 see Metapost 0.9.1

Metapost is an extension that renders MetaPost code included in the wikitext as SVG (or a PNG picture if SVG isn't supported by the browser). This extension defines a new tag  and between this tag and its end tag a user can include MetaPost code.

Example
If you include the following lines in the wikitext

then the result will be this graphics:


 * [[Image:mpexample.png]]

Note that it is only the graphics created in  that gets rendered.

Install software on the wikiserver
 Install a TeX-system on your wikiserver. See, for example, this site. Install imagemagick. Install pdf2svg 

Save the code
Create the directory  and save the code in the files ,   and   respectively, in that directory.

Create an image directory
You need to create a directory where the SVG and PNG files will be stored. For example,. The webserver process also needs to have read and write access to this directory (e.g., by writing something like  on a unix system).

Configure the extension
Add the following lines at the end of the file

where
 * is the full path of the directory where all SVG and PNG files will be stored.
 * is path of  on the webserver.

Bugs and future improvements

 * This extension might be unsafe to use in a public wiki since MetaPost is a full-fledged programming language and it is easy, for example, to write a infinite loop. The extension tries to counteract this by using a few ulimit statements, with wfShellExec, but it is not clear if this is a robust solution.
 * The included graphics might not display on older browsers.

History

 * Version 0.9:Initial version
 * Version 0.9.1:German translation of messages. (Thanks to Ruedi Seiler)
 * Version 0.9.2:Adjusted for use with MediaWiki 1.21.
 * Version 0.9.3:External Python script now rewritten in PHP.