Ajuda: Etiquetas de estilo XML
| Nota: Quando modificais esta página, estais a aceitar que a vossa contribuição se publique no marco de CC0. Olhem Páginas de ajuda de domínio público para mais informação. |
Etiquetas de estilo XML são utilizadas para formatar conteúdos. Esta utiliza a sintaxe:
<nome da etiqueta atributo1="valor1" atributo2="valor2"> conteúdo </nome da etiqueta>
Etiquetas de extensão do analisador
Em qualquer wiki, a página Special:Version mostra as etiquetas de extensão do analisador disponíveis por ordem alfabética.
Por exemplo, nesta wiki, as etiquetas são as seguintes:
<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.
Funções de etiqueta
Cada uma das etiquetas XML tem uma função diferente:
utilizar a função do analisador #tag
You can use the parser function #tag which is a way to create custom HTML tags in MediaWiki in the following ways:
{{#tag:nome da etiqueta|conteúdo}}{{#tag:nome da etiqueta|conteúdo|atributo1=valor1}}{{#tag:nome da etiqueta|conteúdo|atributo1=valor1|atributo2=valor2}}
Também podem ser utilizadas outras formas.
Em baixo está um exemplo antes da expansão:
{{#tag:nome da etiqueta}}{{#tag:nome da etiqueta||atributo1=valor1}}{{#tag:nome da etiqueta||atributo1=valor1|atributo2=valor2}}
{{#tag:nome da etiqueta|conteúdo}}{{#tag:nome da etiqueta|conteúdo|atributo1=valor1}}{{#tag:nome da etiqueta|conteúdo|atributo1=valor1|atributo2=valor2}}
Depois da expansão:
<nome da etiqueta/><nome da etiqueta atributo1="valor1"/><nome da etiqueta atributo1="valor1" atributo2="valor2"/>
<nome da etiqueta> conteúdo </nome da etiqueta><nome da etiqueta atributo1="valor1"> conteúdo </nome da etiqueta><nome da etiqueta atributo1="valor1" atributo2="valor2"> conteúdo </nome da etiqueta>
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.
- 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>.