Jump to content

Help:XML-style tags/ja

From mediawiki.org
This page is a translated version of the page Help:XML-style tags and the translation is 40% complete.
PD 注意: このページを編集すると、編集内容が CC0 のもとで公開されることに同意したと見なされます。詳細はパブリック・ドメインのヘルプ ページを参照してください。 PD

XML-style tags are used to format contents. It uses this syntax:

<タグ名 属性1="値1" 属性2="値2"> content </タグ名>

Parser extension tags

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.

Tag functions

Each of the XML tags there has a different function:

Tag Description
‎<categorytree> Extension:CategoryTree
‎<ce> Deprecated alias for ‎<chem>
‎<charinsert> Extension:CharInsert
‎<chem> Extension:Math/構文
‎<dynamicpagelist> Extension:DynamicPageList
‎<gallery> Help:画像
‎<graph> Extension:Graph (currently not functional on most wikis due to security vulnerabilities)
‎<hiero> Extension:WikiHiero/Syntax
‎<imagemap> Extension:ImageMap
‎<indicator> Help:ページ状態インジケーター
‎<inputbox> Extension:InputBox
‎<langconvert> 文字体系/構文
‎<languages> Help:Extension:Translate
‎<mapframe>, ‎<maplink> Help:Extension:Kartographer
‎<math> Extension:Math/構文
‎<nowiki> Help:高度な編集 , Manual:Template expansion process#Intermediate results
‎<phonos> Help:Extension:Phonos
‎<poem> Extension:Poem
‎<pre> Help:高度な編集 , Manual:Template expansion process#Intermediate results
<ref name="...">, ‎<references> Help:Footnotes
‎<rss> Extension:RSS
<section begin="...">, <section end="..."> Extension:Labeled Section Transclusion
<source lang="..."> Deprecated alias for ‎<syntaxhighlight>
<syntaxhighlight lang="..."> Extension:SyntaxHighlight
‎<templatedata> Extension:TemplateData
‎<templatestyles> Extension:TemplateStyles
‎<timeline> Extension:EasyTimeline/構文

Using the #tag parser function

You can use the parser function #tag which is a way to create custom HTML tags in MediaWiki in the following ways:


{{#tag:タグ名|content}}
{{#tag:タグ名|content|属性1=値1}}
{{#tag:タグ名|content|属性1=値1|属性2=値2}}

Other ways can be used too.

Below is an example before expansion:

{{#tag:タグ名}}
{{#tag:タグ名||属性1=値1}}
{{#tag:タグ名||属性1=値1|属性2=値2}}
{{#tag:タグ名|content}}
{{#tag:タグ名|content|属性1=値1}}
{{#tag:タグ名|content|属性1=値1|属性2=値2}}

After expansion:

<タグ名/>
<タグ名 属性1="値1"/>
<タグ名 属性1="値1" 属性2="値2"/>
<タグ名> content </タグ名>
<タグ名 属性1="値1"> content </タグ名>
<タグ名 属性1="値1" 属性2="値2"> content </タグ名>

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.

Non-parser tags

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.

  • <noinclude>, <includeonly>, <onlyinclude>: See Help:Template#Controlling template inclusion.
  • Most ‘safe’ HTML tags: 'b', 'del', 'i', 'ins', 'u', 'font', 'big', 'small', 'sub', 'sup', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'cite', 'code', 'em', 's', 'strike', 'strong', 'tt', 'var', 'div', 'center', 'blockquote', 'ol', 'ul', 'dl', 'table', 'caption', 'pre', 'ruby', 'rt' , 'rb' , 'rp', 'p', 'span', 'u', 'br', 'hr', 'li', 'dt', 'dd', 'td', 'th', 'tr', see Help:HTML in wikitext
  • <!-- ... -->: The content within these is ignored entirely (It doesn't even become a comment in the resulting HTML). See Help:Comment tags
  • XML-style tags that don't meet the above criteria are rendered as-is, including HTML tags not allowed in wikitext. For example, <script>alert(1);</script><foo>bar</foo> is parsed unchanged, appearing as <script>alert(1);</script><foo>bar</foo>.

See also