[phpcvsview-cvs-updates] phpcvsview/geshi geshi.php,1.1,1.2
Status: Pre-Alpha
Brought to you by:
bcheesem
From: Brian C. <bch...@us...> - 2004-12-22 11:06:25
|
Update of /cvsroot/phpcvsview/phpcvsview/geshi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8352/geshi Modified Files: geshi.php Log Message: - Further cleanup of default theme. - Altered GeSHi code to add a basic highlighter detection. - Optimised some of the XHTML output from the theme. Index: geshi.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/geshi/geshi.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** geshi.php 20 Dec 2004 07:28:58 -0000 1.1 --- geshi.php 22 Dec 2004 11:06:00 -0000 1.2 *************** *** 2411,2413 **** --- 2411,2472 ---- } + /** + * function: guess_highlighter + * --------------------------- + * This function attempts to identify the highlighter to use for a + * given file extension. + */ + function guess_highlighter($fileExtension) + { + $highlightmappings = array( + 'as' => 'actionscript', + 'ada' => 'ada', + 'conf' => 'apache', + 'asm' => 'asm', + 'asp' => 'asp', + 'sh' => 'bash', + 'c' => 'c,c_mac,objc', + 'dcl' => 'caddcl', + 'lisp' => 'cadlisp,lisp', + 'cpp' => 'cpp', + 'c++' => 'cpp', + 'cxx' => 'cpp', + 'cs' => 'csharp', + 'css' => 'css', + 'pas' => 'delphi,pascal', + 'htm' => 'html4script', + 'html' => 'html4script', + 'java' => 'java', + 'js' => 'javascript', + 'lua' => 'lua', + 'nsi' => 'nsis', + 'bas' => 'oobas,qbasic', + 'pl' => 'perl', + 'php' => 'php,php-brief', + 'php3' => 'php,php-brief', + 'php4' => 'php,php-brief', + 'php5' => 'php,php-brief', + 'py' => 'python', + 'tpl' => 'smarty', + 'sql' => 'sql', + 'vb' => 'vb,vbnet', + 'fky' => 'visualfoxpro', + 'xml' => 'xml' + ); + + $highlighter = $highlightmappings[$fileExtension]; + if ($highlighter == null) { + $highlighter = ""; + } + $pos = strpos($highlighter, ","); + if ($pos === false) { + return $highlighter; + } + else + { + $arr = explode(",", $highlighter); + return $arr; + } + } + ?> |