Names to HTML for Wikipedia Article for CodeProject

by clayshannon

HTML

<h2>The Eagles Have Landed</h2>

<p>If you have a list of names of famous people such as this:</p>

<ul>
	<li>Glenn Frey</li>
	<li>Don Henley</li>
	<li>Bernie Leadon</li>
	<li>Randy Meisner</li>
	<li>Joe Walsh</li>
	<li>Timothy B. Schmit</li>
	<li>Don Felder</li>
	<li>Jackon Browne</li>
	<li>J.D. Souther</li>
</ul>

<p>...you may want to linkify the names to point to their respective wikipedia articles. To do so is not difficult, 

because wikipedia follows a standard formats for its entries - in most cases for proper names, it simply replaces the 

space between the first and last name with a space, like so: "Chris Hillman" becomes "Chris_Hillman". The link for the 

Byrdman of Bakersfield (poetic license) is: href="http://en.wikipedia.org/wiki/Chris_Hillman"</p>

<p>There's always an exception, though (there may be an exception to that rule, too, which would be nice). In this 

case, though, there's no exception to the exception rule (oh, pooh!), so we have to watch out for "special cases" 

such as names with initials. In this case, wikipedia retains the period but places an underscore after it, such as: 

http://en.wikipedia.org/wiki/A._A._Milne</p>

<p>Still, programatically transforming names into the accepted format is pretty easy. Here's some example code; you 

can pass the name of any person with a wikipedia page to the Wikipidify() method to get back the appropriate HTML 

for the link to that wikipedia page</p>

<p>The sample code uses names of current and former members of The Eagles (the Eagles from Southern California, 

not the Philadelphia Eagles, football fans), along with the names of some affiliated/associated people, such as "The 

Fifth Eagle," Jackson Browne, as well as J.D. Souther. A fictional character, Rupert Pupkin ("The King of Comedy") is 

also included to show what happens when a person in the list does not have a wikipedia page (the link is created fine, 

but clicking it takes you to a "Winchester Mystery page."</p>

<pre...