Markup spec/BNF/Links

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 element and add its current definition wherever it would otherwise be used? I think it makes logical sense to keep the top-level definition, but I have separated out the definitions, which I hope will aid clarity. --HappyDog 13:46, 29 May 2006 (UTC)

Internal links
		::=   [ "#"  ] [ [] ]  []

/* Parser actually considers namespace and subpages to just be part of the article-title, and deals with them later. */ 		::= [ | ":" ] [

/* if subpages: */ /* not properly fleshed out, haven't tried all the combinations */          ::= [ | ":"] [ | "/"  | { "../" } []

        ::= { [<title-legal-chars> | "%" ] } +

/* Specified using regex format, obviously... */ <title-legal-chars>    ::= " %!\"$&'*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+" - ":"

<interwiki-prefix>	::= ":" ::= STRING_FROM_DB

<namespace-prefix>	::= [ ] ":" ::= STRING_FROM_CONFIG /* is it? parser.php gives it as "[_0-9A-Za-z\x80-\xff]" */

<link-description>	::= LEGAL_ARTICLE_ENTITY <extra-description>	::= [<extra-description>]

<internal-link-start>	::= "" <internal-link-end>	::= ""



/* Almost anything seems to be allowed, but it won't necessarily be treated as an actual section title */ <section-id>           ::= { [<title-legal-chars> | "%" | "#" ] } +


 * 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, [] ) and converts it back to an external link.

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.

(* section-ids are technically tolerated currently. but they do nothing and aren't used. *) (* similarly a pipe without a sort key is technically tolerated but isn't useful. *) ::= <internal-link-start> <category-namespace> ":" <article-title> [ <sort-key> ] <internal-link-end>

<category-namespace>   ::= NS_CATEGORY (* set in languages/messages/MessagesXx.php. By default, "Category" *)

(* <article-title> specified above. for a category, it's possibly more restrictive. *) (* other bits specified above. *)


 * 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.

Internal link to HTML
URL = <a href=$1?title=$2$3"$4 title="$2">$5$6</a>

Where

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