Extension:Metapost

What can this extension do?
This extension adds a new tag to allow wiki page authors to include METAPOST graphics into wiki pages.

The following software is required for this extension to work:
 * 1) METAPOST (version >= 0.993)
 * 2) ImageMagick (version >= 6.2)
 * 3) Ghostscript

Usage
The following wiki page content will render a page like this one.

This is a demo:

input boxes;%

beginfig(0) path p[]; p1 = fullcircle xscaled 30 yscaled 100 rotated 75; p2 = ((.2,0) .. (.5,.1) .. (.7,.4) .. (.9,.7)       .. (.9,1) .. (.5,1) ..(.3, .7) .. (.3, .4) .. cycle) scaled 70 shifted (-50,-50); fill p1 withcolor .5[red, white]; fill p2 withcolor .5[red+green, white];

begingroup save t,u; (t1-0, u1) = subpath(0,2) of p1 intersectiontimes p2; (t2-2, u2) = subpath(2,4) of p1 intersectiontimes p2; (t3-4, u3) = subpath(4,6) of p1 intersectiontimes p2; (t4-6, u4) = subpath(6,8) of p1 intersectiontimes p2;

p3 = subpath(t2, t3) of p1        -- subpath(t1, 0) of p1 & subpath(8,t4) of p1	 -- cycle; endgroup;

draw p3;

boxit.line1(btex MetaPost diagram etex); boxit.line2(btex containing \TeX\ symbols etex); boxit.line3(btex embedded in etex); boxit.line4(btex a Wikipedia page etex);

(0,0) = line1.s - line2.n       = line2.s - line3.n        = line3.s - line4.n;

drawoptions(withcolor .5blue); drawunboxed(line1); drawoptions(withcolor .5red); drawunboxed(line2); drawoptions(withcolor .5green); drawunboxed(line3); drawoptions(withcolor .5(red+blue)); drawunboxed(line4);

drawoptions(withcolor .5(blue+green)); draw btex $\int_{-\infty}^{+\infty} e^{-{1\over2}z^2} dz            = \sqrt{2\pi}$ etex rotated 15 shifted(-30,0); endfig;

That's all folks!

Installation

 * 1) Download the gzipped source code
 * 2) Decompress the file and rename it to
 * 3) Put   into your MediaWiki extensions directory.
 * 4) Change   to load the extension.  (See )

Parameters
These parameters can be set in after   is loaded:

Changes to LocalSettings.php
require_once("$IP/extensions/Metapost.php");

Code
Please fetch it from http://www.cs.hku.hk/~sdlee/Metapost/Metapost.php.gz

New version of this extension
As the above link leads nowhere and the implementation is nowhere to be found, I endeavored to write a new version of this extension, as following:

MikTex on Windows
Getting this new version to work with MikTex on a windows installation requires these steps:


 * MikTex/bin is in the path (and the machine is rebooted so that Apache picks up the change)
 * Rather than passing the the full path to the mp file in create_image we have to chdir and use the file name only:


 * The $wgTmpDirectory global has to be pointed to a path with no spaces
 * The $wgImageMagickConvertCommand global needed to point to the convert function
 * References to files ending in .1 should be changed to .0 (for some reason this is the terminus that MikTex uses)