|
HomeNewsExamplesDemoDownloadsFAQDocumentationMailing ListsLicense | |||||||||
11:36 am GMT
Frequently Asked QuestionsContents
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:
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('geshi.php'); // Make a new GeSHi object, with the source, language and path set $source = 'echo "hello, world!"; // weeeeee!!!!'; $language = 'php'; $path = 'geshi/'; $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('geshi.php'); if ( get_magic_quotes_gpc() ) $_POST['source'] = stripslashes($_POST['source']); $source = $_POST['source']; $language = $_POST['language']; $path = 'geshi/'; $geshi = new GeSHi($source, $language, $path); $geshi->set_overall_style('background-color: #ffffee;', 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 'ignore SSL objSrvHTTP.open "POST", "https://example.com/geshi/getgeshi.php?", false, "username", "password" 'nt authentication objSrvHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" objSrvHTTP.send "source=" + Server.URLEncode(Source) + "&language=" + Language GetGeshi = Replace (objSrvHTTP.responseText," ","") 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. |