Extension:Parser Fun

The Parser Fun extension Enhances MediaWiki with the following features:

The "THIS:" prefix
is a prefix for site information related magic words. With PAGENAME for example it can be used as. This allows to get the information from the page the phrase actually is literally defined on instead of the page which is being parsed and where the phrase was expanded into. is a synonym for. If  is being used with an unsupported variable it will be interpreted as template call. Currently the following functions are supported: as well as their URL-encoded equivalents ending with. It is possible for other extensions to support the  prefix, currently it is supported by
 * FULLPAGENAME
 * PAGENAME
 * BASEPAGENAME
 * SUBPAGENAME
 * SUBJECTPAGENAME
 * TALKPAGENAME
 * NAMESPACE
 * SUBJECTSPACE
 * ARTICLESPACE
 * TALKSPACE
 * All Subpage Fun extension variables.

#parse parser function
is a new parser function to do several parser tasks manually on wikitext. The following can be achieved by the parse parser function:
 * Parsing wikitext
 * Unstripping  and general stripped text

By default parse will simply parse the wikitext it receives within its first parameter. There are other parameters to fulfill certain tasks as well:
 * 1 : First parameter is the text which should be parsed and/or unstripped. Don't use, it will ignore all   always and can't be omitted. The parameter value will always be expanded, so it makes sense to use certain templates to escape wikitext first. E.g.:
 * parse : Boolean value whether the input text should really be parsed (can be used to just unstrip some text).
 * unstrip : Defines whether and what kind of content should be unstripped (restored). The following values are allowed:
 * none - nothing will be unstripped (default)
 * nowiki - content within  will be unstripped. Note: certain characters will be escaped after outstripping, so it might not be very useful for parsing that unstripped text.
 * general - everything else than  will be unstripped. This can be content which is intended to be HTML for example.
 * all - will unstrip both, nowiki and general content.

variable / parser function
is a new variable and parser function introduced in Parser Fun 0.2. This basically is a template call-stack accessors. Used within a template which is included in a page, this will return the name of the page which has included the template where  is defined at. It is also possible to return the caller of the caller or a even more distant caller by giving an explicit index like. on the other hand would return the same as  would return. It is possible to give a negative index as well,  for example would return the top-level page, equally to. If the index is not represented within the stack, an empty string will be returned.

In addition, there are the following parameters which can be used with the parser function variant of :
 * 1 / mode : can be the level of the call stack to return (see explanation above). Instead of a number one of the following modes can be set:
 * count - in this mode the current callstack level will be returned. For example  defined on the main page would return  . Defined in a template directly used by the main page, the same would return.
 * list - will return a list of all sites in the stack, including the page where  is defined.
 * linked : boolean whether page(s) should be returned linked.
 * sep : separator between pages in list mode. ' ' by default. Since ' ' is an allowed character in page names, you might want to use ' ' as delimiter in case you are planning on further processing this data.
 * offset : first stack item to return in list mode, where  represents the stacks top (page where   is defined on). Default is  . If negative, the list starts that far from the stacks top. This also works as limiter in count mode (default   in count mode).
 * limit : how many items to return in list mode. If negative the list will end that far from the stacks top. This also works as limiter in count mode.

Information for Developers
If you are developer of an magic words or parser function extension such as Extension:Subpage Fun, you can adjust your extension to work with Parser Funs This: as well. Parser Fun provides a hook called GetThisVariableValueSwitch:


 * Define Function :
 * Attach Hook :

The hook works similar to the ParserGetVariableValueSwitch. For more information on hooks, see Manual:Hooks.

Configuration
These configuration variables have to be set in the LocalSettings file after inclusion of Parser Fun.


 * : Configuration variable (array) to define which Parser Fun functions should be enabled. To disable parse parser function and only enable the this prefix, one can use: