|
|
|
HomeNewsExamplesDemoDownloadsFAQDocumentationMailing ListsLicense | ||||||||||||||
|
9:05 pm 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:
What does GeSHi mean?Apart from the obvious - Generic Syntax Hilighter - GeSHi stands for "Summer Solstice" in Chinese - appropriate, considering the colourful output of GeSHi.
What are the requirements for GeSHi?GeSHi requires PHP >= 4.1.0. It *should* be OS independent - if you're a windows 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 :). Send them to oracle dot shinoda at gmail dot com. 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. Keep checking back - 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?)
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! 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. |