Extension:TernaryPipedLinks

Ternary Piped Links provides shortcut link markup to avoid repetition in writing piped links in certain common situations. It is a generalization of the "Pipe trick".

What can this extension do?
The Ternary Piped Links extension extends link markup with a shortcut in situations when the link title and the displayed text have a common ending. The standard so-called "pipe trick" allows for a shortcut for displaying only the part of the wiki name after the first colon. For example, in interwiki links, e.g. to Wikipedia, you do not want every link to display with a "w:" in front, so you type

However, this trick goes only so far. For example, if you have more than one colon, e.g. if you feel an urge to say that Miranche simply WikiLoves the Pipe trick, you need to type



In the same vein, to add some context to a link on the Montenegrin Royal House of Petrović-Njegoš, you need to type

 

Similarly, to simply have a link that says what it does, e.g. "Go to Main Page", you again need to repeat yourself:

 

This extension provides a simple shortcut markup for these situations.

Usage
The link markup is extended to allow for two pipe delimiters, which break the link into three parts (hence "ternary"). The parts are, in order,
 * Title start: the start of the title of link target.
 * Text start: the start of displayed link text.
 * Common end: the common ending to both.

The extension turns the ternary link into a regular piped link as follows:

becomes

Examples
In the three above situations:


 * 1) displays as Miranche simply WikiLoves the Pipe trick
 * 2) displays as Montenegrin Royal House of Petrović-Njegoš
 * 3) displays as Go to Main Page

Limitations
TernaryPipedLinks does not currently allow a way to specify a common beginning between the link title and displayed text, or more generally a common middle. This would come in useful, for example, when frequently linking to pages that need to be disambiguated. The "pipe trick" does provide some functionality in this regard, e.g. to display just the movie title in a link to the 1954 adaptation of A Star is Born you only need to type

However, trying a more complicated link, such as the one to the 1954 adaptation of A Star is Born still requires repetition:

Also, this extension limits the extent to which the pipe (|) can be used in article titles, though doing so does not look like a good idea in the first place.

Download and Installation
Please cut and paste the code found below and place it in

Then the following to LocalSettings.php:

Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.