Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
121 lines (84 sloc) 4.58 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; %&#33;\&quot;$&amp;&#39;()&#42;,\\&#45;.\\/0&#45;9&#58;&#59;&#61;?@A&#45;Z\\\\^_`a&#45;z~\\x80&#45;\\xFF+&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