Setup GeSHi Filter for syntax highlighting in drupal

I needed a good way to display all kinds of source code in my site, and during my research I found a module called GeSHI Filter, which was exactly what I was looking for.
This module integrates the PHP library GeSHI (Generic Syntax Highlighter) into Drupal. Here's the step to install it onto drupal:.

  • Upload GeSHI filter to sites/all/modules
  • Upload GeSHI library to sites/all/modules/geshifilter
  • Enable the module
  • Enable the GeSHI filter in the input format
  • Create a new story, and put your source code into a tag like this: <code type='java'></code>
  • If you use FCKEditor, you'll need to add a line in all/modules/fckeditor/fckeditor.config.js:
    FCKConfig.ProtectedSource.Add( /<code type[\s\S]*?<\/code>/gi );
  • Then FCKEditor won't bother to parse the <code> tag 

 class myfirstjavaprog
 {  
         public static void main(String args[])
         {
            System.out.println("Hello World!");
         }
 }
 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer