Navigation
Home News Examples Demo Downloads FAQ Documentation Mailing Lists License
Support GeSHi!
If you're using GeSHi, why not help GeSHi out? You can link to GeSHi with this image:
Powered by GeSHi
Get the HTML

Project Status
The latest stable version of GeSHi is 1.0.8.11, released on the 19th of Aug, 2012.

Supported Languages:
*ABAP
*Actionscript
*ADA
*Apache Log
*AppleScript
*APT sources.list
*ASM (m68k)
*ASM (pic16)
*ASM (x86)
*ASM (z80)
*ASP
*AutoIT
*Backus-Naur form
*Bash
*Basic4GL
*BlitzBasic
*Brainfuck
*C
*C for Macs
*C#
*C++
*C++ (with QT)
*CAD DCL
*CadLisp
*CFDG
*CIL / MSIL
*COBOL
*ColdFusion
*CSS
*D
*Delphi
*Diff File Format
*DIV
*DOS
*DOT language
*Eiffel
*Fortran
*FourJ's Genero
*FreeBasic
*GetText
*glSlang
*GML
*gnuplot
*Groovy
*Haskell
*HQ9+
*HTML
*INI (Config Files)
*Inno
*INTERCAL
*IO
*Java
*Java 5
*Javascript
*KiXtart
*KLone C & C++
*LaTeX
*Lisp
*LOLcode
*LotusScript
*LScript
*Lua
*Make
*mIRC
*MXML
*MySQL
*NSIS
*Objective C
*OCaml
*OpenOffice BASIC
*Oracle 8 & 11 SQL
*Pascal
*Perl
*PHP
*Pixel Bender
*PL/SQL
*POV-Ray
*PowerShell
*Progress (OpenEdge ABL)
*Prolog
*ProvideX
*Python
*Q(uick)BASIC
*robots.txt
*Ruby
*Ruby on Rails
*SAS
*Scala
*Scheme
*Scilab
*SDLBasic
*Smalltalk
*Smarty
*SQL
*T-SQL
*TCL
*thinBasic
*TypoScript
*Uno IDL
*VB.NET
*Verilog
*VHDL
*VIM Script
*Visual BASIC
*Visual Fox Pro
*Visual Prolog
*Whitespace
*Winbatch
*Windows Registry Files
*X++
*XML
*Xorg.conf

GeSHi 1.0.8.11 is the current stable release, with eighteen new languages and bug fixes over the last release.

GeSHi 1.1.2alpha5 is the current latest version from the development branch, with full C support (see the GeSHi development website).
Subscribe
RSS 2
Mailing Lists
HomeNewsExamplesDemoDownloadsFAQDocumentationMailing ListsLicense 
2:44 am GMT

Frequently Asked Questions


Contents


What is GeSHi?

GeSHi is a syntax highlighter for HTML, written in PHP. Basically, you input the source you want to highlight and the name of the language you want to highlight it in, and GeSHi returns the syntax-highlighted result. But it doesn't stop there - GeSHi has many powerful and unique features, including:

  • The ability to change the styles of any highlighted element on the fly
  • Use of CSS classes to reduce the amount of output produced (GeSHi can also produce a stylesheet to be used with a language on the fly)
  • XHTML 1.0 Strict + CSS2 compliance
  • Auto-caps/noncaps of keywords
  • Line numbering (both normal and fancy forms, see the demo
  • And many more!


GeSHi supports many different languages - see the list on the left for the list of languages currently officially supported.



What does GeSHi mean?

Apart from the obvious - Generic Syntax Hilighter - GeSHi stands for "Summer Solstice" in Japanese - appropriate, considering the colourful output of GeSHi. Additionally GeSHi in Chinese stands for Format.



What are the requirements for GeSHi?

GeSHi requires PHP >= 4.3.0, although some features will be disabled automatically in versions of PHP < 4.3.3. It *should* be OS independent - if you're a Mac user of GeSHi, please tell me how it goes!



Where can I get GeSHi?

GeSHi is a Sourceforge project - all downloads of GeSHi are through Sourceforge at the GeSHi download page.



How do I use GeSHi?

GeSHi comes with documentation in the docs/ directory. Please read that thoroughly! But here's a quick demo:

// Simple GeSHi demo

// Include the GeSHi library
include(&#039;geshi.php&#039;);

// Make a new GeSHi object, with the source, language and path set
$source = &#039;echo "hello, world!";
// weeeeee!!!!&#039;;
$language = &#039;php&#039;;
$path = &#039;geshi/&#039;;

$geshi = new GeSHi($source, $language, $path);

// and simply dump the code!
echo $geshi->parse_code();



I've found a bug! What do I do?

If you have found what looks like a bug, firstly check the BUGS file in the docs/ directory to see if it hasn't already been identified. Then please post it to the GeSHi bug tracker at Sourceforge. Please also post any information you think might be relevant to the bug - your version of PHP and webserver, what code you were using to highlight, and any error messages you recieve.



I think this feature would be cool! How do I suggest it?

If you want to request a new feature, post it to the GeSHi Feature Request Tracket. That way I can keep tabs on what features people want and get more information from you about them in an orderly fashion.



Can you add this language to GeSHi?

Adding languages is easy - why not try to make a language file for GeSHi yourself? If, however, you cannot make a language file, post a feature request for it, and I will look into making one for release in the next version of GeSHi.



I have made a language file, can you include it with GeSHi?

Sure, as long as nobody has sent me a better one before yours :). In addition to this you should check your language file to pass the test provided in the Language File Validation Script provided with version 1.0.8 and above of GeSHi. If your language passes those tests you'll have a good chance of having it added to the official release. Send it to nigel at geshi dot org. GeSHi has the power to support many languages, you're most welcome to make as many language files as you like!



When will the next GeSHi be released?

I cannot guarantee a release date for *any* release of GeSHi. I'm a student, so sometimes university calls for my attention, but I do try to do as much work on it as possible. All the same, check the news for the latest updates - I'll post progress reports there.



What features will be in the next GeSHi release?

In general, the TODO file in the previous release will contain some things that will be added, but in general not all of them. Also if you're really curious about ongoing developement you might look into the SVN repository at SourceForge directly. Keep checking back - and sometimes new feature plans are posted as news.



Why can't GeSHi point out syntax errors in the code?

GeSHi is not a lexical parser, unlike other highlighting solutions. Therefore, GeSHi has no idea whether the source is correct or not - it only highlights things it recognises. So GeSHi cannot point out errors in the code.

In addition, this means that any source you wish to highlight should be syntactically correct for your language - GeSHi and the associated language file will generally highlight it correctly if so.



GeSHi adds backslashes to my source code! Why?

GeSHi does no such thing. If you're getting errenous backslashes in your highlighted code, that is because you have not run the sourcecode through stripslashes (perhaps because you got the source from a form or a database?)

Also you might get messed up source where strings seem to never end. In this case you did probably a call to stripslashes, but after highlighting - simply use stripslashes before highlighting your code with GeSHi. GeSHi simply highlights what it gets - and if there are slashes involved it highlights them!



How can I use GeSHi under ASP?

Using a bit of trickery it is possible to use GeSHi under ASP. I am aware of at least a couple of people who have done this, and Nathan Palmer sent me the following instructions:

"Here is how I got it done. There may be a better way, but this is the
only way I could figure it out.

Installed PHP 5.0.4 using the manual instructions on
http://us3.php.net/manual/en/install.windows.manual.php

Downloaded GeSHi and put it under a subfolder called "geshi" of my
wwwroot.

Created a file called "getgeshi.php" with these contents.

<?php
include(&#039;geshi.php&#039;);

if ( get_magic_quotes_gpc() ) $_POST[&#039;source&#039;] = stripslashes($_POST[&#039;source&#039;]);
$source = $_POST[&#039;source&#039;];
$language = $_POST[&#039;language&#039;];
$path = &#039;geshi/&#039;;

$geshi = new GeSHi($source, $language, $path);
$geshi->set_overall_style(&#039;background-color: #ffffee;&#039;, true); //to match my wiki
echo $geshi->parse_code();
?>


Then in my ASP code I created a function called GetGeSHi with these
contents.

Function GetGeSHi(Source, Language)
       Dim objSrvHTTP
       Set objSrvHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
       objSrvHTTP.SetOption 2, 13056 &#039;ignore SSL
       objSrvHTTP.open "POST",
"https://example.com/geshi/getgeshi.php?", false, "username",
"password" &#039;nt authentication

       objSrvHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
       objSrvHTTP.send "source=" + Server.URLEncode(Source) + "&language=" + Language
       GetGeshi = Replace (objSrvHTTP.responseText,"&nbsp;","")
End Function


There are a couple of lines in the ASP GetGeSHi function that are
specific to formatting on my wiki. But other than that it simply posts
to the getgeshi.php page and retrieves the contents. It actually
performs quite well although I haven't done any formal time tests."


Nathan has graciously allowed me to put this information in the FAQ for all to use, thanks to him!



How can I use GeSHi under Java?

For Java there have been multiple approaches available for quite some time. The first approach basically works simular to the one presented for ASP, i.e. calling an external server that executes GeSHi for you. BUT there exists a way to execute GeSHi right from your Java VM although this requires some work. For more details have a look at GeSHi4J.



Tabs in a Textarea/WYSIWYG editor?

You may have a textarea
that you want to allow people to write code into, but you also want them to be able to put
tabs into the textarea without the normal copy+paste trick. mouser at donationcoder dot com
(thank you for your donation!) pointed out this useful article to allow people to
use the tab key normally in a textarea.



How can I help with GeSHi?

There are many ways you can help with the developement of GeSHi. One of the easiest ways is to write a new language file or improve an existing one. Another much appreciated way to help is pointing out problems with specific language files, general errors, performance issues or other improvements you think would improve GeSHi some more. Also we are continiously looking for source code samples (snippets) for various language files to get a good coverage for the testcases and to maintain the quality you always wanted.

If there wasn't the right way to offer your support for GeSHi yet you still are welcome to help out with the costs of maintaining the website or donate something for the ongoing developement.

Finally you are asked to tell people about this project to further its use on the web.



What systems support GeSHi or make use of it?

There are quite a lot of different projects using GeSHi for many different things. Plugins and Addons exist at least for the followong systems (which I know about): phpBB (v2, v3 not yet AFAIK), WordPress, Typo3, Joomla!, OpenOffice, MediaWiki (actually used on Wikipedia!), DokuWiki, net2ftp, and many many more!



Where to find translations to other languages and additional resources?

There are quite a lot of additional resources available which you can find using your favorite search engine. In addition there are information about GeSHi available in various other languages.

Materials in other langauges are available in various languages. There's a Serbo-Croatian translation by Jovana Milutinovich from webhostinggeeks.com if you like.