Help:XML-style tags

XML-style tags use a syntax such as <tagname attribute1="value1" attribute2="value2"> content </tagname >.

Parser extension tags edit

On any MediaWiki wiki Special:Version shows the parser extension tags available on that wiki, in alphabetical order. MediaWiki versions of Wikimedia projects gives these links for all Wikimedia wikis on one page.

For Meta this is the following list:

<categorytree>, <charinsert>, <dynamicpagelist>, <gallery>, <hiero>, <imagemap>, <inputbox>, <math>, <nowiki>, <poem>, <pre>, <ref>, <references>, <section>, <source>, <syntaxhighlight> and <timeline>

On the English Wikipedia the list is the same, except that it is without <dynamicpagelist> and <section>.

Also a list of installed parser hooks is given, which also determine the parser extension tags in addition to the standard tags ("core tag hooks"), which are <gallery>, <math>, <nowiki>, and <pre> (and <html> if raw HTML is allowed) [1]

Tag function edit

Calls of the parser function #tag can be of one of the following forms:

{{#tag:tagname|content}}
{{#tag:tagname|content|attribute1=value1}}
{{#tag:tagname|content|attribute1=value1|attribute2=value2}}
etc.

After identifying the wikitexts for the content, the attribute names and the values, each is expanded. If the name attribute1 is the same as the name attribute2 then value1 is discarded (like in a template call, but unlike in #switch, where "a=b|a=c" is equivalent with "a=b"). Finally,

{{#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}}
etc.

are expanded to, respectively:

<tagname/>
<tagname attribute1="value1"/>
<tagname attribute1="value1" attribute2="value2"/>
<tagname> content </tagname >
<tagname attribute1="value1"> content </tagname >
<tagname attribute1="value1" attribute2="value2"> content </tagname >
etc.

Note that content has a fixed position after the first "|", and "=" inside its expanded wikitext has no special meaning in this expansion step, so regardless of whether it contains "=", the whole text is taken. A "|" in content must be entered as {{!}}, except in e.g. [[...|...]]; thus e. g. an external link in timeline can be entered in the form [...{{!}}...].

The tag function can be a useful alternative of the XML-style tag pair itself, which does not expand the wikitexts for the content and the attribute names and values. With the tag fuction they can contain parameters, variables, parser functions and templates. For nowiki and pre the choice depends on the desired effect. For most other extensions the tag function is more versatile. A disadvantage can be that double braces intended for the expanded wikitext of content can affect the parsing of the tag function call. Such double braces could be in the TeX code for the math extension; they can be avoided without affecting the result by a space between the two braces. For a tag without content and without attributes such as <references/> the slightly longer {{#tag:references}} has hardly advantages.

Other edit

See also edit

Notes edit

Links to other help pages

Help contents
Meta · Wikinews · Wikipedia · Wikiquote · Wiktionary · Commons: · Wikidata · MediaWiki · Wikibooks · Wikisource · MediaWiki: Manual · Google
Versions of this help page (for other languages see further)
What links here on Meta or from Meta · Wikipedia · MediaWiki
Reading
Go · Search · Namespace · Page name · Section · Backlinks · Redirect · Category · Image page · Special pages · Printable version
Tracking changes
Recent changes (enhanced) | Related changes · Watching pages · Diff · Page history · Edit summary · User contributions · Minor edit · Patrolled edit
Logging in and preferences
Logging in · Preferences
Editing
Starting a new page · Advanced editing · Editing FAQ · Export · Import · Shortcuts · Edit conflict · Page size
Referencing
Links · URL · Interwiki linking · Footnotes
Style and formatting
Wikitext examples · CSS · Reference card · HTML in wikitext · Formula · Lists · Table · Sorting · Colors · Images and file uploads
Fixing mistakes
Show preview · Reverting edits
Advanced functioning
Expansion · Template · Advanced templates · Parser function · Parameter default · Magic words · System message · Substitution · Array · Calculation · Transclusion
Others
Special characters · Renaming (moving) a page · Preparing a page for translation · Talk page · Signatures · Sandbox · Legal issues for editors
Other languages: