Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
139 lines (103 sloc) 5.92 KB

This page references elements defined in Markup spec/BNF/Fundamental elements and Markup spec/BNF/Article title

Internal and external links work fundamentally differently in MediaWiki, and should likely be treated separately. --Brion VIBBER 04:08, 29 May 2006 (UTC)
Do you mean to separate out their definitions, or to remove the <link></link> element and add its current definition wherever it would otherwise be used? I think it makes logical sense to keep the top-level <link></link> definition, but I have separated out the definitions, which I hope will aid clarity. --HappyDog 13:46, 29 May 2006 (UTC)

Table of Contents

Link definitions

Top level definition

&amp;lt&#59;link&amp;gt&#59;			&#58;&#58;&#61; &amp;lt&#59;internal&#45;link&amp;gt&#59; &#124; &amp;lt&#59;external&#45;link&amp;gt&#59;

Internal links

/&#42; if subpages&#58; &#42;/
/&#42; not properly fleshed out, haven not tried all the combinations &#42;/
&amp;lt&#59;article&#45;link&amp;gt&#59;          &#58;&#58;&#61; &#91;&amp;lt&#59;interwiki&#45;prefix&amp;gt&#59; &#124; &quot;&#58;&quot;&#93; &#91;&amp;lt&#59;namespace&#45;prefix&#93; &amp;lt&#59;article&#45;title&amp;gt&#59;
                         &#124; &quot;/&quot; &amp;lt&#59;article&#45;title&amp;gt&#59;
                         &#124; &#123; &quot;../&quot; &#125; &#91;&amp;lt&#59;article&#45;title&amp;gt&#59;&#93;

&amp;lt&#59;article&#45;title&amp;gt&#59;         &#58;&#58;&#61; &#123; &#91;&amp;lt&#59;title&#45;legal&#45;chars&amp;gt&#59; &#124; &quot;%&quot; &#93; &#125; +

/&#42; Specified using regex format, obviously... &#42;/
&amp;lt&#59;title&#45;legal&#45;chars&amp;gt&#59;  &#58;&#58;&#61; &quot; &quot; &#124; &quot;%&quot; &#124; &quot;&#33;&quot; &#124; &quot;&quot;&quot; &#124; &quot;$&quot; &#124; &quot;&amp;&quot; &#124; &quot;&#39;&quot; &#124; &quot;(&quot; &#124; &quot;)&quot;
 &#124; &quot;&#42;&quot; &#124; &quot;,&quot; &#124; &quot;&#45;&quot; &#124; &quot;.&quot; &#124; &quot;/&quot;
 &#124; &quot;0&quot; &#124; &quot;1&quot; &#124; &quot;2&quot; &#124; &quot;3&quot; &#124; &quot;4&quot; &#124; &quot;5&quot; &#124; &quot;6&quot; &#124; &quot;7&quot; &#124; &quot;8&quot; &#124; &quot;9&quot;
 &#124; &quot;&#58;&quot; &#124; &quot;&#59;&quot; &#124; &quot;&#61;&quot; &#124; &quot;?&quot; &#124; &quot;@&quot;
 &#124; &quot;A&quot; &#124; &quot;B&quot; &#124; &quot;C&quot; &#124; &quot;D&quot; &#124; &quot;E&quot; &#124; &quot;F&quot; &#124; &quot;G&quot; &#124; &quot;H&quot; &#124; &quot;I&quot; &#124; &quot;J&quot; &#124; &quot;K&quot; &#124; &quot;L&quot; &#124; &quot;M&quot;
 &#124; &quot;N&quot; &#124; &quot;O&quot; &#124; &quot;P&quot; &#124; &quot;Q&quot; &#124; &quot;R&quot; &#124; &quot;S&quot; &#124; &quot;T&quot; &#124; &quot;U&quot; &#124; &quot;V&quot; &#124; &quot;W&quot; &#124; &quot;X&quot; &#124; &quot;Y&quot; &#124; &quot;Z&quot;
 &#124; &quot;\&quot; &#124; &quot;^&quot; &#124; &quot;_&quot; &#124; &quot;`&quot;
 &#124; &quot;a&quot; &#124; &quot;b&quot; &#124; &quot;c&quot; &#124; &quot;d&quot; &#124; &quot;e&quot; &#124; &quot;f&quot; &#124; &quot;g&quot; &#124; &quot;h&quot; &#124; &quot;i&quot; &#124; &quot;j&quot; &#124; &quot;k&quot; &#124; &quot;l&quot; &#124; &quot;m&quot;
 &#124; &quot;n&quot; &#124; &quot;o&quot; &#124; &quot;p&quot; &#124; &quot;q&quot; &#124; &quot;r&quot; &#124; &quot;s&quot; &#124; &quot;t&quot; &#124; &quot;u&quot; &#124; &quot;v&quot; &#124; &quot;w&quot; &#124; &quot;x&quot; &#124; &quot;y&quot; &#124; &quot;z&quot;
 &#124; &quot;~&quot;
 &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot;
 &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot;
 &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot;�&quot; &#124; &quot; &quot; &#124; &quot;¡&quot; &#124; &quot;¢&quot; &#124; &quot;£&quot; &#124; &quot;¤&quot; &#124; &quot;¥&quot; &#124; &quot;¦&quot;
 &#124; &quot;§&quot; &#124; &quot;¨&quot; &#124; &quot;©&quot; &#124; &quot;ª&quot; &#124; &quot;«&quot; &#124; &quot;¬&quot; &#124; &quot;­&quot; &#124; &quot;®&quot; &#124; &quot;¯&quot; &#124; &quot;°&quot; &#124; &quot;±&quot; &#124; &quot;²&quot; &#124; &quot;³&quot;
 &#124; &quot;´&quot; &#124; &quot;µ&quot; &#124; &quot;¶&quot; &#124; &quot;·&quot; &#124; &quot;¸&quot; &#124; &quot;¹&quot; &#124; &quot;º&quot; &#124; &quot;»&quot; &#124; &quot;¼&quot; &#124; &quot;½&quot; &#124; &quot;¾&quot; &#124; &quot;¿&quot; &#124; &quot;À&quot;
 &#124; &quot;Á&quot; &#124; &quot;Â&quot; &#124; &quot;Ã&quot; &#124; &quot;Ä&quot; &#124; &quot;Å&quot; &#124; &quot;Æ&quot; &#124; &quot;Ç&quot; &#124; &quot;È&quot; &#124; &quot;É&quot; &#124; &quot;Ê&quot; &#124; &quot;Ë&quot; &#124; &quot;Ì&quot; &#124; &quot;Í&quot;
 &#124; &quot;Î&quot; &#124; &quot;Ï&quot; &#124; &quot;Ð&quot; &#124; &quot;Ñ&quot; &#124; &quot;Ò&quot; &#124; &quot;Ó&quot; &#124; &quot;Ô&quot; &#124; &quot;Õ&quot; &#124; &quot;Ö&quot; &#124; &quot;×&quot; &#124; &quot;Ø&quot; &#124; &quot;Ù&quot; &#124; &quot;Ú&quot;
 &#124; &quot;Û&quot; &#124; &quot;Ü&quot; &#124; &quot;Ý&quot; &#124; &quot;Þ&quot; &#124; &quot;ß&quot; &#124; &quot;à&quot; &#124; &quot;á&quot; &#124; &quot;â&quot; &#124; &quot;ã&quot; &#124; &quot;ä&quot; &#124; &quot;å&quot; &#124; &quot;æ&quot; &#124; &quot;ç&quot;
 &#124; &quot;è&quot; &#124; &quot;é&quot; &#124; &quot;ê&quot; &#124; &quot;ë&quot; &#124; &quot;ì&quot; &#124; &quot;í&quot; &#124; &quot;î&quot; &#124; &quot;ï&quot; &#124; &quot;ð&quot; &#124; &quot;ñ&quot; &#124; &quot;ò&quot; &#124; &quot;ó&quot; &#124; &quot;ô&quot;
 &#124; &quot;õ&quot; &#124; &quot;ö&quot; &#124; &quot;÷&quot; &#124; &quot;ø&quot; &#124; &quot;ù&quot; &#124; &quot;ú&quot; &#124; &quot;û&quot; &#124; &quot;ü&quot; &#124; &quot;ý&quot; &#124; &quot;þ&quot; &#124; &quot;ÿ&quot; &#124; &quot;+&quot;

&amp;lt&#59;interwiki&#45;prefix&amp;gt&#59;	&#58;&#58;&#61; &amp;lt&#59;interwiki&amp;gt&#59; &quot;&#58;&quot;
&amp;lt&#59;interwiki&amp;gt&#59;		&#58;&#58;&#61; STRING_FROM_DB

&amp;lt&#59;namespace&#45;prefix&amp;gt&#59;	&#58;&#58;&#61; &#91;&amp;lt&#59;namespace&amp;gt&#59;&#93; &quot;&#58;&quot;
&amp;lt&#59;namespace&amp;gt&#59;		&#58;&#58;&#61; STRING_FROM_CONFIG
/&#42; is it? parser.php gives it as  &quot;&#91;_0&#45;9A&#45;Za&#45;z\x80&#45;\xff&#93;&quot; &#42;/

&amp;lt&#59;link&#45;description&amp;gt&#59;	&#58;&#58;&#61; LEGAL_ARTICLE_ENTITY
&amp;lt&#59;extra&#45;description&amp;gt&#59;	&#58;&#58;&#61; &amp;lt&#59;letter&amp;gt&#59; &#91;&amp;lt&#59;extra&#45;description&amp;gt&#59;&#93;

&amp;lt&#59;internal&#45;link&#45;start&amp;gt&#59;	&#58;&#58;&#61; &quot;&#91;&#91;&quot;
&amp;lt&#59;internal&#45;link&#45;end&amp;gt&#59;	&#58;&#58;&#61; &quot;&#93;&#93;&quot;

&amp;lt&#59;pipe&amp;gt&#59;			&#58;&#58;&#61; &quot;&#124;&quot;

/&#42; Almost anything seems to be allowed, but it won&#39;t necessarily be treated as an actual section title &#42;/
&amp;lt&#59;section&#45;id&amp;gt&#59;            &#58;&#58;&#61; &#123; &#91;&amp;lt&#59;title&#45;legal&#45;chars&amp;gt&#59; &#124; &quot;%&quot; &#124; &quot;&#35;&quot; &#93; &#125; + 
Remarks
Logically, internal-link should be matched in preference to external-link, as that's how the current parser does it. However, the current parser also explicitly checks for an accidental match of an external link in an inside link (that is, [[http://foo.com]]) and converts it back to an external link.
if (preg_match(&amp;&#35;39&#59;/^\b(?&amp;&#35;58&#59;&amp;&#35;39&#59; . wfUrlProtocols() . &amp;&#35;39&#59;)/&amp;&#35;39&#59;, $m&amp;&#35;91&#59;1&amp;&#35;93&#59;)) &amp;&#35;123&#59; $s .&amp;&#35;61&#59; $prefix . &amp;&#35;39&#59;&amp;&#35;91&#59;&amp;&#35;91&#59;&amp;&#35;39&#59; . $line &amp;&#35;59&#59; continue&amp;&#35;59&#59; &amp;&#35;125&#59;

Categories

In the current parser, categories are just a mildly special case of an internal link. But to the user they seem quite different, and the final behaviour is very different. So let's treat them specially.

/&#42; &amp;lt&#59;article&#45;title&amp;gt&#59; specified above. for a category, it&#39;s possibly more restrictive. &#42;/
/&#42; other bits specified above. &#42;/

Remarks
A link *to* a category is handled by internal-link above.

Rendering

A category link produces no inline text. However, the fact of the link (with possible manual sort key) is stored, and possibly rendered by the skin.

External links

&amp;lt&#59;external&#45;link&#45;start&amp;gt&#59;	&#58;&#58;&#61; &quot;&#91;&quot;
&amp;lt&#59;external&#45;link&#45;end&amp;gt&#59;	&#58;&#58;&#61; &quot;&#93;&quot;

Transformations

Internal link to HTML

 URL = <a href="$2$3$4 title=$2">$5$6</a>

Where

 if &lt;interwiki&gt;&lt;/interwiki&gt; is blank
   $1 = internal variable $wgScript
 else
   $1 = looked up in DB, based on value of &lt;interwiki&gt;&lt;/interwiki&gt;
 $2 = &lt;namespace&#45;prefix&gt;&lt;/namespace&#45;prefix&gt; &lt;article&#45;link&gt;&lt;/article&#45;link&gt;
 If destination page exists
   $3 = "'''''&amp;amp;action=edit'''''"
   $4 = "''''' class="new"'''''"
 else
   $3 and $4 are blank
 If &lt;description&gt;&lt;/description&gt; is blank
   $5 = &lt;article&#45;link&gt;&lt;/article&#45;link&gt;
 else
   $5 = &lt;description&gt;&lt;/description&gt;
 $6 = &lt;extra&#45;description&gt;&lt;/extra&#45;description&gt;

BNF/Links