Posting Source Code In Your Blogs

After going thru numerous fail attempts, and was almost on the verge of giving up, I finally found this gem.

I tried browsing thru the web, searching for ways of how to post up my source codes in my blog, with a decent display look.

Some are pathetic.

Some are too troublesome.

Some are very not user friendly,

while others look pretty awesome, but the javascript just somehow doesn’t align and are not compatible with the sites or blogs. They just simple doesn’t work. (I guess it’s some java scripting conflict or stuff like that)

Until I reached this place.

Trust me. If you are still looking for a plugin/script that does source code citing, syntax highlighting, or something that allows your to post your source code in a website or blog with a “WOW” effect. Look no further. This source code display is the ONE.

Here are a few stuff that I really like about it:-

  • Display your source code in a pretty neat and tidy manner
  • Auto add in line numbers
  • support syntax highlighting for a full load bunch of languages.
  • very user friendly. (All you need is just to add a ‘pre’ tag).
  • very easy to install.
  • And a lot more flexibility that you can configure.

Ok. Enough about the rant. Let’s roll on to business.

Here’s how getting it started:-


1. Add this code right before your tag …

<link href='http://alexgorbatchev.com/pub/sh/2.1.364/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/2.1.364/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shCore.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPerl.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushXml.js' type='text/javascript'></script>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.1.364/scripts/clipboard.swf'
SyntaxHighlighter.all();
</script>
<head>

See the shBrushPerl.js (line 04) there? You can add some other languages’ *.js file if you are using posting other languages source code. You can find the full list of supported files here.

2. That’s all. Whenever you want to post your source to your website / blogs, just call a ‘pre’ tag with the class pointing to the language *.js file library, like this:-

<pre class=”brush:perl”>

sub calculateFullStochastic
{
  my ($data, $x, $y) = @_;
  # calculating the %K(fast) Full Stochastic of $x-days'
  for (my $i=0; $i<@$data-$x; $i++)
  {
    my $highestHigh    = &highestHighForPastDays($data, $i, $x);
    my $lowestLow        = &lowestLowForPastDays($data, $i, $x);
    my $recentClose    = $data->[$i]{Close};
    my $k=50;
    if ($highestHigh-$lowestLow != 0)
    {
      $k    = 100 * ( ($recentClose-$lowestLow) / ($highestHigh-$lowestLow) );
    }
    $data->[$i]{"Stoch_$x_1"} = $k;
  } # for

} # calculating the %K(full) Full Stochastic of $x-days'

</pre>

Enjoy ^_^

==================================================

tag : perl, html, xml, syntax highlighting, code citation, display, css, java script

  6 Responses to “Posting Source Code In Your Blogs”

  1. great share, great article, very usefull for me…thank you

  2. Just want to say what a great blog you got here!
    I’ve been around for quite a lot of time, but finally decided to show my appreciation of your work!

    Thumbs up, and keep it going!

    Cheers
    Christian, iwspo.net

  3. Thanks for posting this!

  4. Every one admits that humen’s life seems to be not very cheap, nevertheless we require cash for various issues and not every one gets enough cash. Hence to get fast business loans or just sba loan will be a proper way out.

  5. Thanks for posting the source code examples! Very helpful.

  6. hey that was really great about positing of the source code in the blogs……thanks a lot

 Leave a Reply

(required)

(required)


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   

Visitors Since Nov 2009

© 2012 Lionel's Blog Suffusion theme by Sayontan Sinha