Jump to content

Nápověda:Značky ve stylu XML

From mediawiki.org
This page is a translated version of the page Help:XML-style tags and the translation is 100% complete.

K formátování obsahu se používají tagy ve stylu XML. Používá se tato syntaxe:

<NazevTagu atribut1="hodnota1" atribut2="hodnota2"> obsah </NazevTagu>

Značky rozšíření parseru

Na jakékoli wiki stránka Special:Version zobrazuje dostupné tagy rozšíření parseru v abecedním pořadí.

Například na této wiki jsou tagy následující:

  • ‎<categorytree>
  • ‎<ce>
  • ‎<charinsert>
  • ‎<chem>
  • ‎<dynamicpagelist>
  • ‎<gallery>
  • ‎<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.

Funkce značek

Každý z XML tagů má jinou funkci:

Značka Popis
‎<categorytree> Extension:CategoryTree
‎<ce> Zastaralý alias pro ‎<chem>
‎<charinsert> Extension:CharInsert
‎<chem> Extension:Math/Syntax
‎<dynamicpagelist> Extension:DynamicPageList
‎<gallery> Nápověda:Obrázky
‎<hiero> Extension:WikiHiero/Syntax
‎<imagemap> Extension:ImageMap
‎<indicator> Nápověda:Indikátory stavu stránky
‎<inputbox> Rozšíření:InputBox
‎<langconvert> Writing systems/Syntax
‎<languages> Nápověda:Extension:Translate
‎<mapframe>, ‎<maplink> Nápověda:Rozšíření:Kartographer
‎<math> Extension:Math/Syntax
‎<nowiki> Nápověda:Pokročilé úpravy , Manual:Template expansion process#Intermediate results
<noinclude>, <includeonly>, <onlyinclude> Help:Template#Controlling template inclusion; wikitext uvnitř těchto textů je zpracován normálně
‎<phonos> Nápověda:Rozšíření:Phonos
‎<poem> Extension:Poem
‎<pre> Nápověda:Pokročilé úpravy , Manual:Template expansion process#Intermediate results
<ref name="...">, ‎<references> Help:Footnotes
‎<rss> Rozšíření:RSS
<section begin="...">, <section end="..."> Extension:Labeled Section Transclusion
<source lang="..."> Zastaralý alias pro ‎<syntaxhighlight>
<syntaxhighlight lang="..."> Extension:SyntaxHighlight
‎<templatedata> Rozšíření:TemplateData
‎<templatestyles> Extension:TemplateStyles
‎<timeline> Rozšíření:EasyTimeline/syntax

Použití funkce parser #tag

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


{{#tag:NazevTagu|obsah}}
{{#tag:NazevTagu|obsah|atribut1=hodnota1}}
{{#tag:NazevTagu|obsah|atribut1=hodnota1|atribut2=hodnota2}}

Lze použít i jiné způsoby.

Níže je uveden příklad před rozšířením:

{{#tag:NazevTagu}}
{{#tag:NazevTagu||atribut1=hodnota1}}
{{#tag:NazevTagu||atribut1=hodnota1|atribut2=hodnota2}}
{{#tag:NazevTagu|obsah}}
{{#tag:NazevTagu|obsah|atribut1=hodnota1}}
{{#tag:NazevTagu|obsah|atribut1=hodnota1|atribut2=hodnota2}}

Po rozšíření:

<NazevTagu/>
<NazevTagu atribut1="hodnota1"/>
<NazevTagu atribut1="hodnota1" atribut2="hodnota2"/>
<NazevTagu> obsah </NazevTagu>
<NazevTagu atribut1="hodnota1"> obsah </NazevTagu>
<NazevTagu atribut1="hodnota1" atribut2="hodnota2"> obsah </NazevTagu>

Nejprve je nutné uvést obsah. Pokud je první parametr pojmenovaný (má znaménko rovnosti), znaménko rovnosti se ignoruje a celý řetězec včetně názvu parametru se považuje za obsah. Pokud má obsah hodnotu |, zapište ji jako {{!}}, s výjimkou kontextů jako ....

Standardní syntaxe tagů ve stylu XML, která obvykle neanalyzuje žádný wikitext uvnitř tagu, což je důvod, proč fungují věci jako ‎<nowiki>. Některé tagy, jako například ‎<ref>, ale analyzují wikitext uvnitř tagu jako speciální případ.

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.

  • 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