Talk:Geshi Syntax Highlight extension

From Wickle Wiki

Leading Whitespace

I fixed a bug in my original version of GeSHiHighlight, that causes the typical first endline after the
<code>
tag to show up as a blank line.

The fixed code, and further updates, as they appear are available at ciscavate.org

--Largos

Language Support Function

Thanks for posting your extension, its worked great. Here is a function that builds an array with all the languages suuported, i.e. all the language files in the geshi subdirectory.

/**
* function: geshi_list_languages
* -------------------------
* List supported languages by reading the files in the geshi/geshi subdirectory
*
*/
function geshi_list_languages ( $path = 'geshi/' )
{
	if ($handle = opendir($path)) {
	   /* Loop over the directory. */
	   while (false !== ($file = readdir($handle))) {
	       /* Drop the current and parent dir entries */
	       if( "." !== $file && ".." !== $file )
	       {
		   /* Drop files that dont end with .php */
		   if( ".php" == substr($file, strrpos($file, "."),4))
		   {
		       $lang_list .= substr($file, 0, strrpos($file, ".")).",";
		   }
	       }
	   }

	   closedir($handle);
	}
	return explode(",", $lang_list);
}

I've replaced the $langArray assignment in my version of GeshiSyntaxHighlight.php with the following.

$langArray = geshi_list_languages("extensions\\geshi\\geshi");

JeffK

Awesome addition!

Thanks Jeff, cool hack :)

I've put it up on the official geshi page:

http://ciscavate.org/index.php/MediaWiki_Extensions#MediaWiki_and_GeSHi

Thanks again, -Largos

Personal tools
This site is powered by Queres Tecnologias