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).

Syntax

edit

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 | ... }} 

Functions

edit

Constants

edit

Text

edit

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

Maths

edit

#expr

edit

From ParserFunctions.

{{#expr: expression }}
Returns expression Result

#time

edit

From ParserFunctions.

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

Conditionals

edit

See also w:Help:Conditional expressions

#switch

edit

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

#ifeq

edit

From ParserFunctions.

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

#ifexpr

edit

From ParserFunctions.

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

Strings

edit

#sub

edit

From StringFunctions.

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

#len

edit

From StringFunctions.

{{#len: string }}
Returns string Length

#pos

edit

From StringFunctions.

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

#format

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

Pages

edit

#ifexist

edit

From ParserFunctions.

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

#path

edit

Renamed from ParserFunctions function "rel2abs".

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

Metafunctions

edit

#var

edit

Partially from VariablesExtension.

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

#loop

edit
{{#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