<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Ken Kopczyk &#187; pastebin</title>
	<atom:link href="http://kenkopczyk.com/tag/pastebin/feed/" rel="self" type="application/rss+xml" />
	<link>http://kenkopczyk.com</link>
	<description>Hurdles in .NET WinForms Development</description>
	<lastBuildDate>Sat, 13 Mar 2010 03:50:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='kenkopczyk.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/60348bde5d188332d5268692846b25c7?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Ken Kopczyk &#187; pastebin</title>
		<link>http://kenkopczyk.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://kenkopczyk.com/osd.xml" title="Ken Kopczyk" />
	<atom:link rel='hub' href='http://kenkopczyk.com/?pushpress=hub'/>
		<item>
		<title>Displaying Source Code in a WordPress Post</title>
		<link>http://kenkopczyk.com/2009/02/01/displaying-source-code-in-a-wordpress-post/</link>
		<comments>http://kenkopczyk.com/2009/02/01/displaying-source-code-in-a-wordpress-post/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 04:26:18 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[pastebin]]></category>

		<guid isPermaLink="false">http://kkopczyk.wordpress.com/?p=70</guid>
		<description><![CDATA[While setting up this blog, I came upon my first challenge:  How can you display source code in a WordPress post? There are many solutions to this problem which include various WordPress.org plug-ins.  The problem with the plug-ins is that they don&#8217;t work with freebee WordPress.com blogs.  The simplest solution that I found for WordPress.com [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kenkopczyk.com&amp;blog=6344943&amp;post=70&amp;subd=kkopczyk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While setting up this blog, I came upon my first challenge:  How can you display source code in a WordPress post?</p>
<p>There are many solutions to this problem which include various <a href="http://www.wordpress.org">WordPress.org</a> plug-ins.  The problem with the plug-ins is that they don&#8217;t work with freebee <a href="http://www.wordpress.com">WordPress.com</a> blogs.  The <a href="http://support.wordpress.com/code/#posting-source-code">simplest solution</a> that I found for <a href="http://www.wordpress.com">WordPress.com</a> blogs was to simply wrap the code you want to post in <a href="http://support.wordpress.com/code/#posting-source-code">&#8220;sourcecode&#8221; tags</a> and let javascript take care of the rest.  Implementing this is easy because you don&#8217;t have to worry about a big blob of HTML.  All that is required is the code you want to paste and the javascript tags.  Example:</p>
<pre class="brush: csharp;">
static void Main(string[] args)
{
      Console.Out.WriteLine(&quot;Hello World!&quot;);
      return;
}
</pre>
<p>Being the perfectionist that I am, I wanted to see if I could get the code to look closer to the default fonts and colors used in Visual Studio.  Thanks to <a href="http://robburke.net/2008/08/04/pasting-code-into-wordpress-easily/">this posting</a>, I discovered <a href="http://www.pastebin.com">pastebin.com</a>.  It does a nice job of converting source code into html.  And it has syntax highlighting for most languages, including C#.  To streamline the process, I wrote a parser.  This code will parse the full source of the pastebin output, yank out the relevent html, and add style to make it look close to Visual Studio.  The following source code is a solution to the problem and also a demonstration.  <b>Which method do you think looks better?</b></p>
<div style="font-family:monospace;font-size:1.3em;">
<div style="background:#ffffff;">
<div><span style="color:#0600FF;">using</span> <span style="color:#000000;">System</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div><span style="color:#0600FF;">using</span> <span style="color:#000000;">System</span>.<span style="color:#0000FF;">IO</span>;</div>
</div>
<div style="background:#ffffff;">
<div><span style="color:#0600FF;">using</span> <span style="color:#000000;">System</span>.<span style="color:#0000FF;">Text</span>.<span style="color:#0000FF;">RegularExpressions</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div> </div>
</div>
<div style="background:#ffffff;">
<div><span style="color:#0600FF;">namespace</span> PasteBinCodeScrubber</div>
</div>
<div style="background:#f4f4f4;">
<div><span style="color:#008000;">{</span></div>
</div>
<div style="background:#ffffff;">
<div>    <span style="color:#0600FF;">class</span> Program</div>
</div>
<div style="background:#f4f4f4;">
<div>    <span style="color:#008000;">{</span></div>
</div>
<div style="background:#ffffff;">
<div>        <span style="color:#0600FF;">static</span> <span style="color:#0600FF;">void</span> Main<span style="color:#008000;">(</span><span style="color:#0600FF;">string</span><span style="color:#008000;">[</span><span style="color:#008000;">]</span> args<span style="color:#008000;">)</span></div>
</div>
<div style="background:#f4f4f4;">
<div>        <span style="color:#008000;">{</span></div>
</div>
<div style="background:#ffffff;">
<div>            FileInfo<span style="color:#008000;">[</span><span style="color:#008000;">]</span> allHtmlFiles = <span style="color:#0600FF;">new</span> DirectoryInfo<span style="color:#008000;">(</span><span style="color:maroon;">&#8220;.&#8221;</span><span style="color:#008000;">)</span>.<span style="color:#0000FF;">GetFiles</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;*.htm*&#8221;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            <span style="color:#0600FF;">foreach</span> <span style="color:#008000;">(</span>FileInfo htmlFile <span style="color:#0600FF;">in</span> allHtmlFiles<span style="color:#008000;">)</span></div>
</div>
<div style="background:#ffffff;">
<div>            <span style="color:#008000;">{</span></div>
</div>
<div style="background:#f4f4f4;">
<div>                <span style="color:#0600FF;">string</span> allHtml = File.<span style="color:#0000FF;">ReadAllText</span><span style="color:#008000;">(</span>htmlFile.<span style="color:#0000FF;">FullName</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div> </div>
</div>
<div style="background:#f4f4f4;">
<div>                <span style="color:green;">// capture all relevent html</span></div>
</div>
<div style="background:#ffffff;">
<div>                Regex sourceCodeRegex = <span style="color:#0600FF;">new</span> Regex<span style="color:#008000;">(</span><span style="color:maroon;">&#8220;&lt;div class=<span style="color:#008080;">&#8220;</span>csharp<span style="color:#008080;">&#8220;</span> style=<span style="color:#008080;">&#8220;</span>font-family: monospace;<span style="color:#008080;">&#8220;</span>&gt;&lt;ol&gt;[<span style="color:#008080;">\</span>s<span style="color:#008080;">\</span>S]*?&lt;/ol&gt;&lt;/div&gt;&#8221;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>                <span style="color:#0600FF;">string</span> sourceCodeHtml = sourceCodeRegex.<span style="color:#0000FF;">Match</span><span style="color:#008000;">(</span>allHtml<span style="color:#008000;">)</span>.<span style="color:#0000FF;">Value</span>;</div>
</div>
<div style="background:#ffffff;">
<div> </div>
</div>
<div style="background:#f4f4f4;">
<div>                <span style="color:green;">// doctor the html</span></div>
</div>
<div style="background:#ffffff;">
<div>                sourceCodeHtml = ScrubHtml<span style="color:#008000;">(</span>sourceCodeHtml<span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>                sourceCodeHtml = ReplaceCssClassWithStyle<span style="color:#008000;">(</span>sourceCodeHtml<span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div> </div>
</div>
<div style="background:#f4f4f4;">
<div>                File.<span style="color:#0000FF;">WriteAllText</span><span style="color:#008000;">(</span>htmlFile.<span style="color:#0000FF;">FullName</span> + <span style="color:maroon;">&#8220;.out&#8221;</span>, sourceCodeHtml<span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            <span style="color:#008000;">}</span></div>
</div>
<div style="background:#f4f4f4;">
<div>        <span style="color:#008000;">}</span></div>
</div>
<div style="background:#ffffff;">
<div> </div>
</div>
<div style="background:#f4f4f4;">
<div>        <span style="color:#0600FF;">private</span> <span style="color:#0600FF;">static</span> <span style="color:#0600FF;">string</span> ReplaceCssClassWithStyle<span style="color:#008000;">(</span><span style="color:#0600FF;">string</span> sourceCodeHtml<span style="color:#008000;">)</span></div>
</div>
<div style="background:#ffffff;">
<div>        <span style="color:#008000;">{</span></div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>de1<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:#0600FF;">string</span>.<span style="color:#0000FF;">Empty</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>de2<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:#0600FF;">string</span>.<span style="color:#0000FF;">Empty</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>inp<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: red;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>li1<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>background: #ffffff;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>li2<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>background: #f4f4f4;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>kw1<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #0600FF;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>kw2<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #FF8000;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>kw3<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #0600FF;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>kw4<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #0600FF;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>kw5<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #000000;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>co1<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: green;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>co2<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: green;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>coMULTI<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: green;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>es0<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #008080;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>br0<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #008000;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>st0<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: maroon;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>nu0<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #FF0000;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>me1<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #0000FF;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;class=<span style="color:#008080;">&#8220;</span>me2<span style="color:#008080;">&#8220;</span>&#8220;</span>, <span style="color:maroon;">&#8220;style=<span style="color:#008080;">&#8220;</span>color: #0000FF;<span style="color:#008080;">&#8220;</span>&#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            <span style="color:#0600FF;">return</span> sourceCodeHtml;</div>
</div>
<div style="background:#f4f4f4;">
<div>        <span style="color:#008000;">}</span></div>
</div>
<div style="background:#ffffff;">
<div> </div>
</div>
<div style="background:#f4f4f4;">
<div>        <span style="color:#0600FF;">private</span> <span style="color:#0600FF;">static</span> <span style="color:#0600FF;">string</span> ScrubHtml<span style="color:#008000;">(</span><span style="color:#0600FF;">string</span> sourceCodeHtml<span style="color:#008000;">)</span></div>
</div>
<div style="background:#ffffff;">
<div>        <span style="color:#008000;">{</span></div>
</div>
<div style="background:#f4f4f4;">
<div>            <span style="color:green;">// add font size</span></div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;&lt;div class=<span style="color:#008080;">&#8220;</span>csharp<span style="color:#008080;">&#8220;</span> style=<span style="color:#008080;">&#8220;</span>font-family: monospace;<span style="color:#008080;">&#8220;</span>&gt;&#8221;</span>,</div>
</div>
<div style="background:#f4f4f4;">
<div>                                                    <span style="color:maroon;">&#8220;&lt;div style=<span style="color:#008080;">&#8220;</span>font-family:monospace; font-size:1.3em;<span style="color:#008080;">&#8220;</span>&gt;&#8221;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div> </div>
</div>
<div style="background:#f4f4f4;">
<div>            <span style="color:green;">// remove list tags</span></div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;&lt;ol&gt;&#8221;</span>, <span style="color:#0600FF;">string</span>.<span style="color:#0000FF;">Empty</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;&lt;/ol&gt;&#8221;</span>, <span style="color:#0600FF;">string</span>.<span style="color:#0000FF;">Empty</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;&lt;li &#8220;</span>, <span style="color:maroon;">&#8220;&lt;div &#8220;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span><span style="color:maroon;">&#8220;&lt;/li&gt;&#8221;</span>, <span style="color:maroon;">&#8220;&lt;/div&gt;&#8221;</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div> </div>
</div>
<div style="background:#f4f4f4;">
<div>            <span style="color:green;">// remove hyperlinks</span></div>
</div>
<div style="background:#ffffff;">
<div>            Regex hyperLinkRegex = <span style="color:#0600FF;">new</span> Regex<span style="color:#008000;">(</span><span style="color:maroon;">&#8220;&lt;a href=.*?&gt;(?&#8217;linkWrappedHtml&#8217;[<span style="color:#008080;">\</span>s<span style="color:#008080;">\</span>S]*?)&lt;/a&gt;&#8221;</span>, RegexOptions.<span style="color:#0000FF;">ExplicitCapture</span><span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            MatchCollection hyperLinkMatches = hyperLinkRegex.<span style="color:#0000FF;">Matches</span><span style="color:#008000;">(</span>sourceCodeHtml<span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#ffffff;">
<div>            <span style="color:#0600FF;">foreach</span> <span style="color:#008000;">(</span>Match hyperLinkMatch <span style="color:#0600FF;">in</span> hyperLinkMatches<span style="color:#008000;">)</span></div>
</div>
<div style="background:#f4f4f4;">
<div>            <span style="color:#008000;">{</span></div>
</div>
<div style="background:#ffffff;">
<div>                <span style="color:#0600FF;">string</span> sHtmlInsideHyperLink = hyperLinkMatch.<span style="color:#0000FF;">Groups</span><span style="color:#008000;">[</span><span style="color:maroon;">"linkWrappedHtml"</span><span style="color:#008000;">]</span>.<span style="color:#0000FF;">Value</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>                <span style="color:#0600FF;">string</span> sFullHyperLink = hyperLinkMatch.<span style="color:#0000FF;">Value</span>;</div>
</div>
<div style="background:#ffffff;">
<div>                sourceCodeHtml = sourceCodeHtml.<span style="color:#0000FF;">Replace</span><span style="color:#008000;">(</span>sFullHyperLink, sHtmlInsideHyperLink<span style="color:#008000;">)</span>;</div>
</div>
<div style="background:#f4f4f4;">
<div>            <span style="color:#008000;">}</span></div>
</div>
<div style="background:#ffffff;">
<div> </div>
</div>
<div style="background:#f4f4f4;">
<div>            <span style="color:#0600FF;">return</span> sourceCodeHtml;</div>
</div>
<div style="background:#ffffff;">
<div>        <span style="color:#008000;">}</span></div>
</div>
<div style="background:#f4f4f4;">
<div>    <span style="color:#008000;">}</span></div>
</div>
<div style="background:#ffffff;">
<div><span style="color:#008000;">}</span></div>
</div>
</div>
<p><!-- AddThis Button BEGIN --></p>
<div><a title="Bookmark and Share" href="http://www.addthis.com/bookmark.php?pub=kkopczyk&amp;url=http://kkopczyk.wordpress.com/2009/02/01/displaying-source-code-in-a-wordpress-post/" target="_blank"><img style="border:0;padding:0;" src="http://s7.addthis.com/static/btn/lg-share-en.gif" alt="Bookmark and Share" width="125" height="16" /></a></div>
<p><!-- AddThis Button END --></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kkopczyk.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kkopczyk.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kkopczyk.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kkopczyk.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kkopczyk.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kkopczyk.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kkopczyk.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kkopczyk.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kkopczyk.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kkopczyk.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kkopczyk.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kkopczyk.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kkopczyk.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kkopczyk.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kenkopczyk.com&amp;blog=6344943&amp;post=70&amp;subd=kkopczyk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kenkopczyk.com/2009/02/01/displaying-source-code-in-a-wordpress-post/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/df43ecaeb5e162064d67f882431983c6?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Ken</media:title>
		</media:content>

		<media:content url="http://s7.addthis.com/static/btn/lg-share-en.gif" medium="image">
			<media:title type="html">Bookmark and Share</media:title>
		</media:content>
	</item>
	</channel>
</rss>