XML-style tags are used to format contents. It uses this syntax:
<tagname attribute1="value1" attribute2="value2"> content </tagname>
On any wiki, the Special:Version page shows the available parser extension tags in alphabetical order.
For example, on this wiki, the tags are as follows:
<categorytree>
<ce>
<charinsert>
<chem>
<dynamicpagelist>
<gallery>
<graph>
<hiero>
<imagemap>
<indicator>
<inputbox>
<langconvert>
<languages>
<mapframe>
<maplink>
<math>
<nowiki>
<phonos>
<poem>
<pre>
<ref>
<references>
<rss>
<score>
<section>
<source>
<syntaxhighlight>
<templatedata>
<templatestyles>
<timeline>
The Special:Version page also has a list of installed parser hooks , which work similarly but use slightly different syntax and generally produce more dynamic content or content that can be further postprocessed by other templates.
Each of the XML tags there has a different function:
Using the #tag parser function[edit]You can use the parser function #tag which is a way to create custom HTML tags in MediaWiki in the following ways:
{{#tag:tagname|content}}
{{#tag:tagname|content|attribute1=value1}}
{{#tag:tagname|content|attribute1=value1|attribute2=value2}}
Other ways can be used too.
Below is an example before expansion:
{{#tag:tagname}}
{{#tag:tagname||attribute1=value1}}
{{#tag:tagname||attribute1=value1|attribute2=value2}}
{{#tag:tagname|content}}
{{#tag:tagname|content|attribute1=value1}}
{{#tag:tagname|content|attribute1=value1|attribute2=value2}}
After expansion:
<tagname/>
<tagname attribute1="value1"/>
<tagname attribute1="value1" attribute2="value2"/>
<tagname> content </tagname>
<tagname attribute1="value1"> content </tagname>
<tagname attribute1="value1" attribute2="value2"> content </tagname>
content must be provided first. If the first parameter is named (has an equals sign), the equals sign is ignored and the entire string including the parameter name is treated as the content. If the content has a "|", write it as {{!}}, except in contexts like ....
The standard XML-style tag syntax which usually doesn't parse any wikitext inside the tag, which is what makes things like <nowiki>
work. Some tags like <ref>
do parse the wikitext inside the tag as a special case, though.
The #tag:
parser function, on the other hand, expands all other template calls before sending it to the XML-style tag. For example, with {{T2 }} containing "{{{1}}}", parameter 2 is "{{{2}}}"
:
<nowiki>{{t2|[[foo]]|[[bar]]}}</nowiki>
leaves the template call unexpanded, resulting in {{t2|[[foo]]|[[bar]]}}.{{#tag:nowiki|{{t2|[[foo]]|[[bar]]}}}}
expands the template call but then leaves the wikilinks unexpanded, resulting in Parameter 1 is "[[foo]]", parameter 2 is "[[bar]]".{{t2|[[foo]]|[[bar]]}}
expands everything, resulting in Parameter 1 is "foo", parameter 2 is "bar"For simple tags like <references/>
, using {{#tag:references}}
offers little benefit.
Other XML-style tags do not go through the parser at all. These generally do not work with #tag
, and wikitext inside them is processed normally.
<script>alert(1);</script><foo>bar</foo>
is parsed unchanged, appearing as <script>alert(1);</script><foo>bar</foo>.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4