From Meta, a Wikimedia project coordination wiki

Wikisyntax is a two-fold proposal:

  1. All fancy code should be unified into one consistent language called Wikisyntax.
  2. That language can only be used in the Template namespace.

The intention of this proposal is to clean up the code people see when they edit an article. Whilst markup code is fairly easy to read, fancy code (defined in a minute) clutters up the edit box. Hence I propose moving all of that fancy code into templates, and tidying it up while we're at it.

"Markup" is defined here as the code used to format an article like '''bold''', ''italics'', bullets and numbering, etc. "Fancy code" is anything other than this, such as ParserFunctions and extensions (e.g. {{#if:a|4|5}}, <ref name="foo"></ref>), which most users find complex, confusing, and obfuscatory when editing a page.

By separating fancy code from normal, human-readable code, we clear up the edit box and actually make our wiki languages more consistent. Wikitext remains a pure markup language with no functions at all, and Wikisyntax contains all the functions with no markup.

Internal Extendibility[edit]

The motivation for this proposal is based entirely in how Templates are actually being used. They are not just simple transclusion devices, but have evolved. People wanted to make them handle their parameters and produce dynamic, tailored outputs. This idea was extremely useful: a normal user can simply type, e.g., {{infobox|science|mass|40kg|image=x.jpg}}, and receive a tailored, formatted, calculated, informative output (e.g. an infobox).

Allowing the template namespace to handle "programming" code offers MediaWiki the functionality for its own users to write their own functions that aid their own content. Templates become a kind of custom subroutine in the software. Programmable templates offer internal extendibility to MediaWiki.

This is obviously an extremely fruitful notion, one already effectively in use, but the Wikisyntax proposal keeps complexity out of articles to avoid them being confusing, and ensure that Wikitext remains the markup language it is meant to be (i.e. does nothing but format text).


The best thing about this proposal is that we already have the code for it, in such extensions already implemented as ParserFunctions. To keep things simple, Wikisyntax should have the same syntax as current Parser extensions, that is:

 {{#function: param1 | param2 | param3 | ... }} 




Text not written in Wikisyntax syntax (i.e. {{# ... }} etc.) is treated as constant textual output both inside and outside of functions.



From ParserFunctions.

{{#expr: expression }}
Returns expression Result


From ParserFunctions.

{{#time: format | time }}
time Optional, default = Current Time
Returns time Formatted As format


See also w:Help:Conditional expressions


From ParserFunctions.

{{#switch: value | case(1)=result(1) | case(2)=result(2) | ... | defaultresult }}
defaultresult Optional, default = empty
Returns result(i) If value = case(i), Else Returns defaultresult


From ParserFunctions.

{{#if: string | then | else }}
else Optional, default = empty
Returns then If Not string = empty, Else Returns else


From ParserFunctions.

{{#ifeq: string1 | string2 | then | else }}
else Optional, default = empty
Returns then If string1 = string2, Else Returns else


From ParserFunctions.

{{#ifexpr: expression | then | else }}
else Optional, default = empty
Returns then If expression Result >= 1, Else Returns else



From StringFunctions.

{{#sub: string | start | length }}
start Optional, default = 0
length Optional, default = (string Length - start)
Returns string Substring From start To (start + length)


From StringFunctions.

{{#len: string }}
Returns string Length


From StringFunctions.

{{#pos: string | find | start }}
start Optional, default = 0
Returns Position Of find In string After start


{{#format: string | format }}
Returns string Formatted As format



From ParserFunctions.

{{#ifexist: pagename | then | else }}
else Optional, default = empty
Returns then If pagename Exists, Else Returns else


Renamed from ParserFunctions function "rel2abs".

{{#path: path | pagename }}
pagename Optional, default = Current Page
Returns path In pagename



Partially from VariablesExtension.

{{#var: name | value }}
value Optional, default = null
Returns String $name Value If value = null, Else Sets String $name To value


{{#loop: name | lowerbound | upperbound | wikisyntax }}
Sets Integer $name To lowerbound, Returns wikisyntax Result, Increments Integer $name By 1, Repeats If Integer $name Value <= upperbound

See also[edit]