foodsoft/vendor/plugins/wikicloth/sample_documents/pipe_trick.wiki

69 lines
4.4 KiB
Plaintext
Raw Normal View History

The '''pipe trick''' is a way (or really several ways) to create links without having to type a lot of extra text. The advantage is that you are less likely to make a mistake when you type less. It's also easier for others to edit it. To create the [[pipe character]] ("|") press (SHIFT + BACKSLASH ["\"]) on English-layout and some other keyboards.
When you place a [[Vertical bar|pipe character]] ("'''|'''") after an [[Wikipedia:What is an article?|article]] title which ends with a [[Bracket#Parentheses ( )|parenthesized]] term or contains a [[comma (punctuation)|comma]] or [[Colon (punctuation)|colon]], the [[wiki software]] transforms what you entered. The non-parenthesized part of the article title is used as the visible part of the link. This does not work in edit summaries, and in certain other cases (listed below).
==Examples==
This may be hard to follow, so please see the examples:
{| class="wikitable"
|-
!| Type this
!| Generates this when you "Save page"
!| Appears as
|-
! colspan="3" style="text-align: left;" | Article titles
|-
|| <code><nowiki>[[g (factor)|]]</nowiki></code> || <code><nowiki>[[g (factor)|g]]</nowiki></code> || [[g (factor)|g]]
|-
|| <code><nowiki>[[Boston, Massachusetts|]]</nowiki></code> || <code><nowiki>[[Boston, Massachusetts|Boston]]</nowiki></code> || [[Boston, Massachusetts|Boston]]
|-
|| <code><nowiki>[[The Lord of the Rings: The Fellowship of the Ring (video game)|]]</nowiki></code> || <code><nowiki>[[The Lord of the Rings: The Fellowship of the Ring (video game)|The Fellowship of the Ring]]</nowiki></code> || [[The Lord of the Rings: The Fellowship of the Ring (video game)|The Fellowship of the Ring]]
|-
! colspan="3" style="text-align: left;" | Redirection
|-
|| <code><nowiki>[[Bush (43)|]]</nowiki></code> || <code><nowiki>[[Bush (43)|Bush]]</nowiki></code> || [[Bush (43)|Bush]]
|-
|| <code><nowiki>[[Bush (41)|]]</nowiki></code> || <code><nowiki>[[Bush (41)|Bush]]</nowiki></code> || [[Bush (41)|Bush]]
|-
! colspan="3" style="text-align: left;" | Normal titles
|-
|| <code><nowiki>[[Wikipedia:Help|]]</nowiki></code> || <code><nowiki>[[Wikipedia:Help|Help]]</nowiki></code> || [[Wikipedia:Help|Help]]
|-
! colspan="3" style="text-align: left;" | Users
|-
|| <code><nowiki>[[User:Example|]]</nowiki></code> || <code><nowiki>[[User:Example|Example]]</nowiki></code> || [[User:Example|Example]]
|-
|}
==Where it does not work==
===Cite.php &lt;ref&gt; footnotes===
<!-- The pipe trick auto-converts, for example, <nowiki>[[Roger Taylor (author)|]]</nowiki> to <nowiki>[[Roger Taylor (author)|Roger Taylor]]</nowiki> -->
The trick does not work when enclosing between [[wikipedia:footnotes|"ref" tags]]. <code><nowiki><ref>[[Roger Taylor (author)|]]</ref></nowiki></code><ref>[[Roger Taylor (author)|]]</ref> renders in the references list (generated by the <nowiki><references/></nowiki> tag) as:
<references/>
===Edit summaries===
<!-- The pipe trick auto-converts, for example, <nowiki>[[WP:SAND|]]</nowiki> to [[WP:SAND|SAND]] -->
The trick does not work in edit summaries. <code><nowiki>/* Edit summaries and the pipe trick */ as tested in [[WP:SAND|]]</nowiki></code> renders in the edit history as:
<span class="comment">(<span class="autocomment">[[#Edit summaries and the pipe trick|→]]Edit summaries and the pipe trick:</span> as tested in [[WP:SAND]])</span>
== Slash trick ==
You can achieve the same effect for subpages by adding a slash: <code><nowiki>[[/subpage/]]</nowiki></code> generates the same output as <code><nowiki>[[/subpage|subpage]]</nowiki></code>. Unlike the pipe trick, though, it will not be transformed in the [[wikitext]].
This trick only works in namespaces where <code><nowiki>[[/subpage]]</nowiki></code> would.
== Reverse pipe trick ==
Typing <tt><nowiki>[[|Agonizer]]</nowiki></tt> on, for example, [[Agonist (disambiguation)]] will cause the link to be expanded to <tt>[[[[Agonizer (disambiguation)]]|Agonizer]]</tt>; similarly on a page with a name containing a comma. Using the reverse pipe trick on a page that has no parentheses or comma in its name is unproductive; the pipe character is automatically removed.
==Try it!==
The best way to understand this is to try it yourself in the [[Wikipedia:Sandbox|sandbox]]. Use one of the examples under "Type this" above, save the page, then immediately edit it again. You'll see the transformation, and it should be clearer exactly what happened.
==See also==
* [[Help:Magic]]
* [[Help:Piped link]]
* [[m:Help:Piped link]]
[[Category:Wikipedia features|{{PAGENAME}}]]