# Extension:PGFTikZ

MediaWiki extensions manual
PGFTikZ
Release status: unmaintained
Implementation Tag
Description Parse PGF/TikZ input, generate and compile LaTeX file and upload resulting image
Author(s) Thibault Marin, Markus Bürkler
MediaWiki 1.20+
PHP 5.3+
Database changes No
Parameters

## Installation

• Download and place the file(s) in a directory called PGFTikZ in your extensions/ folder.
require_once "$IP/extensions/PGFTikZ/PGFTikZ.php";  • Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed. ### Configuration parameters The following parameters can be set in the LocalSettings.php page after loading the extension (the values given here are the default values): // Default resolution for generated images$wgPGFTikZDefaultDPI  = 300;

// Full path to LaTeX executable
$wgPGFTikZLaTeXPath = 'latex'; // Command line options to LaTeX command$wgPGFTikZLaTeXOpts = 'no-shell-escape'

// Full path to dvips executable
$wgPGFTikZdvipsPath = 'dvips'; // Either use epstool+imagemagick or ghostscript to generate image$wgPGFTikZuseghostscript = true;

// Full path to 'epstool' executable
$wgPGFTikZepstoolPath = 'epstool'; // Full path to 'ghostscript' executable$wgPGFTikZghostScriptPath = 'gs';

// Use standalone LaTeX package


## Security

Since the extension internally compiles LaTeX documents from user input, security must be considered before deploying the extension on public wikis.

• Some of the possible attacks that must be considered when deploying a web-based LaTeX compilation system are described in the TUG article: "A web-based TeX previewer: The ecstasy and the agony" ([[1]]):
• Execution of the system commands via wfShellExec offers control on resource limits given to the system call using $wgMaxShellMemory and$wgMaxShellTime variables.
• The source stored in the LaTeX file can also compromise security. The texmf.cnf file can be used to block access to files from within the generated LaTeX file. See [[2]] for a discussion on the matter.

Please download the code found below and place it in $IP/extensions/PGFTikZ/. Note:$IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Note that the bitbucket links will be closed once the latest version is merged in the mediawiki repository.

### version 0.3.0

The latest version (with fixes to work on Windows hosted wikis) (v0.3.0, waiting for mediawiki review) is available at: https://bitbucket.org/thibaultmarin/pgftikz_public/get/v0.3.0.zip

### Mediawiki repository

The extension can be retrieved directly from Git [?]:

• Browse code
• Some extensions have tags for stable releases.
• Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).

Extract the snapshot and place it in the extensions/PGFTikZ/ directory of your MediaWiki installation.

If you are familiar with git and have shell access to your server, you can also obtain the extension as follows:

cd extensions/
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/PGFTikZ.git


## Known problems

This is an early stage, expect rough edges. Known bugs/limitations include:

• When using preview and save repeatedly, edit conflicts might occur in some cases. The edit conflict redirects to a resolution page where the input PGF/TikZ code is mixed up with the image automatically generated description page. Cancelling the conflict (maybe even deleting the image) and regenerating the page should fix the problem.
• If two pages link to the same file with different content, the image will be re-compiled each time either page is displayed.
• Probably many more, please report them.