You can now download the module from the GeSHi Filter project page
I am a comp sci student so I often post code on my website. I just happen to use a wonderful CMS/blogger called Drupal that supports filters and all kinds of other goodies. I wanted a filter that would take anything posted in <code> tags and automagically apply syntax highlighting.
GeSHi and Codefilter
My solution was to take the existing codefilter module that drupal provides and intergrate GeSHi into it. All in all it is very simple, you just have to install the codefilter patch and install genshi. Then go to admin -> settings -> codefilter to configure and enable genshi.
Because it is extremely difficult to determine the language from a code fragment you have to do it yourself. There is an option where a default language can be configured. But I wanted to make sure that I could use this for more than one language so I added some options to the <code> tag.
The have the code hightlighted in a language other than the default do this:
If you want to turn it off temporarily do this:
The path can be downloaded below. There is an alternative coloring module called VIM color which uses the coloring schemes from vim. This is arguably more powerful and more tested however it requries certain perl modules and access to perl which limits its usefulness on windows. My module uses a php library called GeSHi so it will run where ever drupal is running. In truth if I would have noticed vim color first I wouldn't have bothered writing this, as it is I may change to it at some point in the future.
Supported Languages
| Actionscript | ADA | Apache Log |
| AppleScript | ASM | ASP |
| Bash | Blitz | Basic |
| C | C for Macs | C# |
| C++ | CAD DCL | CadLisp |
| CSS | Delphi | DIV |
| DOS | Eiffel | FreeBasic |
| GML | HTML | Inno |
| Java | Javascript | Lisp |
| Lua | Microprocessor ASM | MySQL |
| NSIS | Objective C | OCaml |
| OpenOffice | BASIC | Oracle 8 SQL |
| Pascal | Perl | PHP |
| Python | Q(uick)BASIC | Ruby |
| Scheme | SDL | Basic |
| Smarty | SQL | VB.NET |
| Visual BASIC | Visual Fox Pro | XML |
Examples
C
/************************************
*
* error
*
* DESCRIPTION
* Generic output routine for errors.
*
* RETURNS
* void
*
*/
void error( char* file, int line, bool terminal, char *message, ... ) {
va_list ap;
char* temp = strrchr( file, '\\' );
if( temp != NULL )
file = temp+1;
fprintf( stderr, "E|%s:%d ", file, line );Python
# constructor
#
# DESCRIPTION
# Creates an empty set, or a set for a list of
# elements if the list is passed in
#
def __init__( self, list = { } ):
if list != None:
self.set = { }
for i in range( 0, len( list ) ):
self.set[ list[i] ] = ""
else:
selt.set = list
HTML 4 Strict
<div id="header">
<img id="logo" src="/themes/filbar-classic/px/filbar-logo.png" alt="filbar" />
<div id="headerbg">
<div id="date">
Saturday, August 06, 2005 </div>
<ul>
<li><a href="/gallery">Gallery</a></li>
<li><a href="/project">Projects</a></li>
<li><a href="/forum">Forum</a></li>
<li><a href="">Home</a></li>
</ul>
</div>
<div id="search">
<form action="search" method="post">
<input type="text" size="15" value="" name="edit[keys]" />
<input type="submit" value="Search" />
</form>
</div>
<div id="breadcrumb">
<div class="breadcrumb"><a href="">Home</a> » <a href="/node/add">create content</a> » <a href="/node/add/blog">Submit personal blog entry</a></div> </div>
</div>
Java
*
*/
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
public class ImagePanel extends JPanel {
Image image;
public ImagePanel( String path ) {
image = Toolkit.getDefaultToolkit().getImage( path );
setVisible( true );
}
public ImagePanel() {
setVisible( true );
}
}
| Attachment | Size |
|---|---|
| codefilter-geshi.patch | 8.04 KB |











Does your module work with TinyMCE?
Top 10 best gambling roulette gambling casinos based on micro gaming platform.
Best online black jack gambling casinos, play to win and enjoy your online
internet blackjack experience.
Learn how to play video poker and experience the thrill of gambling and beating online casinos.
Use a free poker reviews to calculate your winning poker odds.
Learn the art of horse racing system and play to win your punts at the races.
Dont buy movies, get downloadable movies movies and watch them for free.
Earn money and work from home, with forex trading system, trade the forex market.
Get all sorts of iphone games for your new iphone mobile telephone.
As primarily social animals,wholesale human beings naturally seek out differentchina wholesale
discount groups to which they feel they have a certainMP3 player sense of belonging. MP4 player
mp4 watchesBut there are two different aspectsmp5 of this issue involved: psp accessories
wedding dresses
wedding dressidentifying oneself with a social group forwholesale digital cameras
wholesale clothing its social implications and identifying oneself with a social group for internal needs.wholesale furniture
Memory Card
Memory Stick A person can have two different identities,wholesale atv
wholesale jewelry
wholesale handbags one that involves an individual's self-perception and the way that others see that particular individual. wholesale shoes
wholesale t shirts
Men's outerwearThere is a natural dichotomy between the two sides of one's personality that is usually displayed between the different types of social groups with which an individual may identify definition can either be honest or dishonest. Women's outerwear
Mens outerwearA person may join a social group skin care products
wholesale mp3because he or she thinks that the people that belong to this type of group are the same as he or she,wholesale mobile phones
digital camera wholesale
dropship whether it is true or not. The important detail to the individual is that he or she would like to be the same as the people that belong to this particular social group. As one example, consider a person who grew up poor and poorly educated, consumer electronics
gadgets
wholesale silver jewelrybut became wealthy through the luck of the lottery or an inheritance from an unknown but wealthy relative. gps devicesThis individual then joins a wine-tasting club and buys season tickets to the local Philharmonic Orchestra and opera house. Although this individual knows nothing about wine, orchestras or opera, he or she is seeking to identify him or herself as a culturally literate person simply because the person is now wealthy. wholesale electronicsThrough joining these social groups, the individual is seeking to define him or herself as socially elite,bluetooth headset although the only difference now is that the person has great wealth and in reality probably does not fit in with the other members of the groups.In this case, wholesaleone's self-definition by identifying with wholesale electronics
mp5 playersocial groups does not match up with how society still identifies are individuals that very clearly demonstrate who they are by their identification with certain social groups.memory cards
gps devices
Car video At a very basic level, younger people may join gangs based on a sense of identification with certain gang members or gang ideas. By displaying different identifying tattoos or certain colors, identify who they are and what they stand for by the
Dupral is amazing.. Since learing it my life has become so much easier... Highly recomended...
Tiffany Jewelry Whenever glasses frame I wear my
eyeglasses, I always get acne where the plastic "... Clean
eye glasses the plastic
eyewear bridges with
Tiffany Necklaces rubbing alcohol every
Tiffany Bracelets
Tiffany Rings morning and night to kill the bacteria.
Tiffany
Seems it works. Shame the post has died a little.
Post new comment