Extension:Pipe Escape

What can this extension do?
This extension allows for pipe characters in parser function arguments (and template argument calls) avoid being interpreted as an argument delimiter. This is primarily for the purpose of using wiki tables (or parts thereof) inside parser function calls.

For example, suppose you have the following wikitable in a template:

but you only want the table to show up when a non-whitespace value is supplied for template argument targ. One possible solution is to use HTML instead of wiki syntax

but this is less intuitive and therefore more error-prone, and, in part, defeats the purpose of a wiki. Another solution is to hide the pipe characters from the parser function in a template. (Common practice is to use the template Template:! with its includable contents being only a raw pipe character.)

This is a better solution, but things are a bit messy when you're trying to hide multiple pipes in an argument. This is where this simple parser function comes in handy.

Usage

 *  

This hides the pipe characters in wiki text so that outer parser functions and outer templates do not interpret them as argument delimiters. With this extension, the above example can be rewritten as

In reality, the pipe characters are still treated as argument delimieters in this parser function, but it concatenates the arguments using a pipe character as a separator which outer parser functions do not register as delimiters.

Unlike most parser functions, pipe escape preserves the leading and trailing whitespace around its arguments except the first argument (due to the way MediaWiki handles the first argument in parser functions; See bug 12842), and the trailing whitespace in the last argument.

Pipe escape only affects top-level pipe characters. It does not affect pipe characters in other parser functions nested within the pipe escape parser function call. The same is true for pipe characters in template calls, template arguments, intrawiki links, tag extensions, etc...

Download instructions
Please cut and paste the code found below and place it in. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation
To install this extension, add the following to LocalSettings.php: