better rst error handling
[phorkie.git] / src / phorkie / File.php
index bad21e6edba1db40a1a147e60579aa96b7f696c6..87c38512a0cea0a45bcdb37c6ce7869129fd491d 100644 (file)
@@ -60,15 +60,14 @@ class File
 
     public function getHighlightedContent()
     {
-        /**
-         * Yes, geshi needs to be in your include path
-         * We use the mediawiki geshi extension package.
-         */
-        require_once 'MediaWiki/geshi/geshi/geshi.php';
-        $geshi = new \GeSHi($this->getContent(), $this->getGeshiType());
-        $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
-        $geshi->set_header_type(GESHI_HEADER_DIV);
-        return $geshi->parse_code();
+        $ext = $this->getExt();
+        if (isset($GLOBALS['phorkie']['languages'][$ext]['renderer'])) {
+            $class = $GLOBALS['phorkie']['languages'][$ext]['renderer'];
+        } else {
+            $class = '\\phorkie\\Renderer_Geshi';
+        }
+        $rend = new $class();
+        return $rend->toHtml($this);
     }
 
     /**
@@ -88,21 +87,6 @@ class File
         throw new Exception('Unknown type');
     }
 
-    /**
-     * Returns the type of the file, as used by Geshi
-     *
-     * @return string
-     */
-    public function getGeshiType()
-    {
-        $ext = $this->getExt();
-        if (isset($GLOBALS['phorkie']['languages'][$ext]['geshi'])) {
-            $ext = $GLOBALS['phorkie']['languages'][$ext]['geshi'];
-        }
-
-        return $ext;
-    }
-
     public function getMimeType()
     {
         $ext = $this->getExt();