Content deleted Content added
update from meta |
updated from meta:Help:Parser function |
||
Line 1:
{{h:h|editor toc}}
{{otheruses4|parser functions in general|the MediaWiki extension '''ParserFunctions'''|
▲{{otheruses4|parser functions in general|the MediaWiki extension '''ParserFunctions'''|m:Help:ParserFunctions}}
A '''parser function''' is a [[Help:Template|template]]-like construct which returns a value based on at least one unnamed parameter, separated from the function name by a colon "''':'''"; there may be more parameters which, like those of ordinary templates, are each preceded by "'''|'''". Parser functions differ by a leading [[w:Number sign|hash character]] (#):
Line 51 ⟶ 50:
===ANCHORENCODE===
For anchors ''within'' a page use <nowiki>{{anchorencode}}</nowiki> instead of <nowiki>{{urlencode}}</nowiki>. The results of a call to <nowiki>{{anchorencode}}</nowiki> are compatible with intra-page references generated for <nowiki>[[#link]]</nowiki>s, while <nowiki>{{urlencode}}</nowiki>-generated values are not necessarily so.
Note that (contrary to urlencode) the encoding made by "anchorencode", which uses the dot charactor as a prefix before a byte repesented in hexadecimal, is not fully reversible. "anchorencode" is then NOT suitable for passing query parameters. However the encoding made by "urlencode" (which uses "%" characters) is not compatible with the more restricted character sets allowed in HTML and XML for ids. tHe two encodings also differ in the way they encode the space.
Compare:
* <tt><nowiki>#{{anchorencode:Langue française}}</nowiki></tt> ''return:'' "'''#{{anchorencode:Langue française}}'''" ''(valid only for anchors to sections in MediaWiki pages)'', when
* <tt><nowiki>{{urlencode:Langue française}}</nowiki></tt> ''returns:'' "'''{{urlencode:Langue française}}'''" ''(for paths or query parameters in URLs, excluding anchors)''
The encoding made by anchorencode is suitable to give anchor names within pages made with MdiaWiki.
It is not guaranteed to work with other web sites: if you need to specify an anchor in a page not hosted on a server running MediaWiki, the anchor is not warrantied to work as expected. So, use "anchorencode" only for targetting a MediaWiki web site, such as those from the Xikimedia Foundation projects.
==NS==
|