Manual:Extending wiki markup

I

MediaWiki provides a standard text markup that can be easily customized. Both piecemeal and wholesale customizations are possible:


 * adding standard token types: The standard approach to customized MediaWiki markup is to add new markup that looks like the built-in MediaWiki XML tags, template , or link markup.


 * adding custom token types: Some extensions define new token types.


 * fundamental changes to the parser: A few extensions attempt to fundamentally change the parsing strategy so that markup from other sorts of wikis and content management can be used (must be used?) instead of the standard wiki markup.

Adding to the standard token types
When  is implemented as a parser function, it passes its template parameters to a PHP function instead of the usual template article. This function returns a string of wikitext that replaces the parameterized template. Parser functions are used to handle wikitext generation that involves logic that is too complex or confusing to write using normal template-writing techniques. Instead of the usual article transclusion, is associated with a PHP function that returns a string of wikitext that replaces it. They are usually used to insert system information into wiki markup (e.g., the current time, the current page).
 * : Parser function extensions extend parameterized template processing and typically look something like this: .  Although any "template name" can be used, custom extensions always begin the function name with a #, as in the example above.  Other parser function names are reserved for use by the MediaWiki core.
 * : Variable extensions extend parameterless template processing.
 *  :  XML markup extensions (also known as tag extensions) define custom XML-style tags in the wikitext:  The text between the tags gets passed on to a PHP function which parses the contents of the tag and returns an HTML string that replaces the tag and text.  The content inside the tags may be wiki markup, straight text, or text with formatting rules specific to the tag.  It is up to the extension implementer.  Please check documentation of individual extensions.
 * : Link markup extensions change the way MediaWiki interprets internal links, i.e., wiki markup of the form ....
 * : Extended syntax extensions, mostly Magic Word extensions, add to the list of MediaWiki Magic Words, such as .  Usually, a specific PHP function interprets these words, and either replaces them with something, or sets some conditions for later processing during output generation, or both.  Most usually, the replacement is the empty string; that is, the Magic Word is deleted, and nothing is shown in its place.  Altered processing may involve addition of an extra piece of CSS, or suppression of user preference settings during page generation, and can be almost anything.

Adding new token types
To add new token types or to change the entire markup strategy, implementers need to add functions to one or more of the various parser and page output hooks:


 *  rely on the hook.


 *  rely on the hook.


 *  rely on the hook.


 *  rely on the hook.


 *  rely on the hook.


 *  rely on the hook.