Manual:Extending wiki markup

MediaWiki provides a standard markup text 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. For example, Extension:ParserPhase2, adds several token types: ,  , and.
 * 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
 Parser function extensions: 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. 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 wiki text that replaces the parameterized template. Parser functions are used to handle wiki text generation that involves logic that is too complex or confusing to write using normal template-writing techniques.  Variable extensions: Variable extensions extend parameterless template processing. Instead of the usual article transclusion,  is associated with a PHP function that returns a string of wiki text that replaces it. They are usually used to insert system information into wiki markup (e.g., the current time, the current page).  XML markup extensions: XML markup extensions (also known as tag extensions) define custom XML-style tags in the wikitext:  some text  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: Link markup extensions change the way MediaWiki interprets internal links, i.e., wiki markup of the form ... . Extended syntax extensions: 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:

 Category:ParserBeforeStrip extensions rely on the ParserBeforeStrip hook.</li> Category:ParserAfterStrip extensions rely on the ParserAfterStrip hook.</li> Category:ParserBeforeInternalParse extensions rely on the ParserBeforeInternalParse hook.</li> Category:OutputPageBeforeHTML extensions rely on the OutputPageBeforeHTML hook.</li> Category:ParserBeforeTidy extensions rely on the ParserBeforeTidy hook.</li> Category:ParserAfterTidy extensions rely on the ParserAfterTidy hook.</li> </ul>