Parser testing/replaceInternalLinks

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search

Input[edit]


Plain link, capitalized: [[Main Page]]

Plain link, uncapitalized: [[main Page]]

Piped link: [[Main Page|The Main Page]]

Broken link: [[Zigzagzogzagzig]]

Link with prefix: XXX[[main Page]], XXX[[Main Page]]

Link with suffix: [[Main Page]]XXX

Link with 3 brackets: [[[main page]]]

Piped link with 3 brackets: [[[main page|the main page]]]

Link to namespaces: [[Talk:Parser testing]], [[Meta:Disclaimers]]

Piped link to namespace: [[Meta:Disclaimers|The disclaimers]]

Link to category: [[:Category:MediaWiki handbook]]

Link to image page: [[:Image:Ncwikicol.png]]

Plain link to URL: [[http://www.example.org]]

Piped link to URL: [[http://www.example.org|an example URL]]

Output[edit]

Plain link, capitalized: Main Page

Plain link, uncapitalized: main Page

Piped link: The Main Page

Broken link: Zigzagzogzagzig

Link with prefix: xxxmain Page, xxxMain Page, Xxxmain Page XXXmain Page, XXXMain Page

Link with suffix: Main Pagexxx, Main PageXXX

Link with 3 brackets: [[[main page]]]

Piped link with 3 brackets: [[[main page|the main page]]]

Link to namespaces: Talk:Parser testing, Meta:Disclaimers

Piped link to namespace: The disclaimers

Link to category: Category:MediaWiki handbook

Link to image page: Image:Ncwikicol.png

Plain link to URL: [[1]]

Piped link to URL: [example URL]

Expected[edit]

<p>Plain link, capitalized: <a href="/wiki/Main_Page">Main Page</a></p>
<p>Plain link, uncapitalized: <a href="/wiki/Main_Page">main Page</a></p>
<p>Piped link: <a href="/wiki/Main_Page">The Main Page</a></p>
<p>Broken link: <a href="/w/wiki.phtml?title=Zigzagzogzagzig&action=edit" class="new">Zigzagzogzagzig</a></p>
<p>Link with prefix: xxx<a href="/wiki/Main_Page">main Page</a>, xxx<a href="/wiki/Main_Page">Main Page</a>, Xxx<a href=
"/wiki/Main_Page">main Page</a> XXX<a href="/wiki/Main_Page">main Page</a>, XXX<a href="/wiki/Main_Page">Main Page</a></p>
<p>Link with suffix: <a href="/wiki/Main_Page">Main Pagexxx</a>, <a href="/wiki/Main_Page">Main Page</a>XXX</p>
<p>Link with 3 brackets: [[[main page]]]</p>
<p>Piped link with 3 brackets: [[[main page|the main page]]]</p>
<p>Link to namespaces: <a href="/w/wiki.phtml?title=Talk:Parser_testing&action=edit" class="new">Talk:Parser testing</a>,
<a href="/w/wiki.phtml?title=Meta:Disclaimers&action=edit" class="new">Meta:Disclaimers</a></p>
<p>Piped link to namespace: <a href="/w/wiki.phtml?title=Meta:Disclaimers&action=edit" class="new">The disclaimers</a></p>
<p>Link to category: <a href="/wiki/Category:MediaWiki_handbook">Category:MediaWiki handbook</a></p>
<p>Link to image page: <a href="/wiki/Image:Ncwikicol.png">Image:Ncwikicol.png</a></p>
<p>Plain link to URL: [<a href='http://www.example.org' class='external'>[1]</a> <span class=
'urlexpansion'>(<i>http://www.example.org</i>)</span>]</p>
<p>Piped link to URL: <a href="/w/wiki.phtml?title=Http://www.example.org&action=edit" class="new">an example URL</a></p>