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



MediaWiki takes care of the rest, guessing that you want to drop the "w:". Unfortunately, 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 markup text 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. Doing this would require allowing for up to four pipes, dividing the markup into up to five parts, which is not a problem to implement but seems like overkill from UI design POV. However, such a feature would save trouble with some grammatical constructions, and when 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:



Finally, 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 add the following to :

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