Client-Side code highlighting
When I visited Alex Gorbatchev's blog, I noticed he had a unique client-side code highlighting solution in place, one I hadn't seen anywhere else. That's something I've wanted on my blog for a while; the vanilla <PRE> sections I've been using are servicable, but primitive. Although I loves me some regex, I don't know squat about PERL so I've been hesitant to hack anything fancier into my Movable Type install.
Public Function GetGoogleWordFrequency(ByVal strWord As String) As Integer Dim strUrl As String = "http://www.google.com/search?num=1&q=" & _ Web.HttpUtility.UrlEncode(strWord) Dim wc As New WebClientGzip Dim strPageContents As String = wc.DownloadDataGzip(strUrl) Dim m As Match m = Regex.Match(strPageContents, _ "results.*?d+.*?d+.*?of about.*?(?<TotalResults>[d,]+)", _ RegexOptions.IgnoreCase) If Not m Is Nothing Then Dim strResults As String = m.Groups("TotalResults").ToString If strResults.Length > 0 Then Return Convert.ToInt32(strResults.Replace(",", "")) End If End If Return -1 End Function