From 7c085c3f72c02e35ecb7c323aa8489e91f77ef1b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 28 Mar 2015 00:41:12 +0100 Subject: Get supported mimetypes from pygments itself Signed-off-by: Florian Pritz --- application/libraries/Pygments.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/application/libraries/Pygments.php b/application/libraries/Pygments.php index ab3868087..be59beb90 100644 --- a/application/libraries/Pygments.php +++ b/application/libraries/Pygments.php @@ -145,6 +145,15 @@ class Pygments { ); if (array_key_exists($this->mimetype, $typearray)) return $typearray[$this->mimetype]; + // fall back to pygments own list if not found in our list + $typearray = array(); + foreach (self::get_pygments_info() as $lexer) { + foreach ($lexer['mimetypes'] as $type) { + $typearray[$type] = $lexer['names'][0]; + } + } + if (array_key_exists($this->mimetype, $typearray)) return $typearray[$this->mimetype]; + if (strpos($this->mimetype, 'text/') === 0) return 'text'; # default -- cgit v1.2.3-24-g4f1b