Extension:Pipe Escape

The Pipe Escape 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 or templates.

Use cases
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. 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 (MW ≤ 1.23) or the  magic word (MW ≥ 1.24) 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 delimiters 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 task 14842), 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...