Syntax highlight Makefiles
Syntax highlight Makefiles

This is manually handled in GitPHP because GeSHi works purely off of
extensions and doesn't handle filenames without extensions. Adding
support for that into the GeSHi code itself would make merging updates
to GeSHi harder, so this is done in GitPHP code for now.

Feature #109

--- a/include/Util.class.php
+++ b/include/Util.class.php
@@ -129,5 +129,24 @@
 		return $filename;
 	}
 
+	/**
+	 * GeshiFilenameToLanguage
+	 *
+	 * Provides a geshi language for a given filename
+	 *
+	 * @access public
+	 * @param string $filename file name
+	 * @return string language
+	 * @static
+	 */
+	public static function GeshiFilenameToLanguage($filename)
+	{
+		if (strncasecmp($filename, 'Makefile', 8) === 0) {
+			return 'make';
+		}
+
+		return null;
+	}
+
 }
 

--- a/include/controller/Controller_Blame.class.php
+++ b/include/controller/Controller_Blame.class.php
@@ -144,7 +144,10 @@
 			if (class_exists('GeSHi')) {
 				$geshi = new GeSHi("",'php');
 				if ($geshi) {
-					$lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(),'.'),1));
+					$lang = GitPHP_Util::GeshiFilenameToLanguage($blob->GetName());
+					if (empty($lang)) {
+						$lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(),'.'),1));
+					}
 					if (!empty($lang)) {
 						$geshi->enable_classes();
 						$geshi->enable_strict_mode(GESHI_MAYBE);

--- a/include/controller/Controller_Blob.class.php
+++ b/include/controller/Controller_Blob.class.php
@@ -201,7 +201,10 @@
 			if (class_exists('GeSHi')) {
 				$geshi = new GeSHi("",'php');
 				if ($geshi) {
-					$lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(),'.'),1));
+					$lang = GitPHP_Util::GeshiFilenameToLanguage($blob->GetName());
+					if (empty($lang)) {
+						$lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(),'.'),1));
+					}
 					if (!empty($lang)) {
 						$geshi->enable_classes();
 						$geshi->enable_strict_mode(GESHI_MAYBE);

comments