Friday, April 21, 2006

BLOGGER: You can use GeSHi in your blogger posts

You can use GeSHi in your blogger posts. Simply use your own PHP server and install GeSHi. Then you can use the following code to post code snippets to your blog.



A few notes:

1. You must tell blogger to not convert your line breaks. If you don't it'll screw up the PHP code.

2. You must have your blogger set to create an index.php or the like.

3. Change the 'php' below to the proper language based on what you're posting.




Code Example © Robert Mech. May be used freely as long as credit is given to the source.





<?php
include_once('geshi/geshi.php');



$source = <<<END



// SOURCE CODE HERE



END;



$geshi = new GeSHi($source, 'php');

$geshi->set_header_type(GESHI_HEADER_DIV);



echo $geshi->parse_code();


?>


If you use this code, please make a comment on the blog!


No comments: