Template:Wikilink

From Bitcoin Wiki
Revision as of 23:46, 4 March 2015 by TheRealSteve (talk | contribs) (Asked around - apparently there is no existing functionality.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Documentation for Wikilink

. This is a template that can check whether a given input is a wiki link, and extract the link / text from that link.

A wiki link is defined as a link that is inserted using [...] for internal links or [[...]] for external links.

The template takes 1 required parameter (the input string), and 1 optional parameter. The optional parameter can be one of link (returns the link portion, if applicable) or text (returns the text portion, if applicable).

The template can be used with #if to check if the input is an internal wiki link (returns 1), external wiki link (returns 2), or neither (returns nothing).

This template probably doesn't work for all variants of wiki links - although it does work with the Pipe Trick.

For an overview, see the examples/test cases table below:

inputrenders asoutput{{#if:...|true|false}}-test
gibberishgibberishfalse
gibberish|linkfalse
gibberish|textfalse
[[internal link]]internal link1true
[[internal link]]|linkinternal linktrue
[[internal link]]|textfalse
[[internal link|some text]]some text1true
[[internal link|some text]]|linkinternal linktrue
[[internal link|some text]]|textsome texttrue
[[internal link|some text]]overflowsome textoverflow1true
[[internal link|some text]]overflow|linkinternal linktrue
[[internal link|some text]]overflow|textsome textoverflowtrue
[http://www.example.com/][1]2true
[http://www.example.com/]|linkhttp://www.example.com/true
[http://www.example.com/]|textfalse
[http://www.example.com/ some text]some text2true
[http://www.example.com/ some text]|linkhttp://www.example.com/true
[http://www.example.com/ some text]|textsome texttrue
[[Help:Pipe Trick|]]Pipe Trick1true
[[Help:Pipe Trick|]]|linkHelp:Pipe Tricktrue
[[Help:Pipe Trick|]]|textPipe Tricktrue
[[pipe (computing)|]]millpipemill1true
[[pipe (computing)|]]mill|linkpipe (computing)true
[[pipe (computing)|]]mill|textpipemilltrue